diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-14 04:01:05 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-14 04:01:05 +0000 |
commit | 9c3d9bb6a4cad2c63d23ad4283c81da25db7c836 (patch) | |
tree | 803ba42a7e6795e6651b3ffaf5af2b677b9a134a | |
parent | 0cdd4e004f50064b1507d7313665860bc9aaeb2d (diff) |
merge revision(s) 26033:
* lib/bigdecimal.rb: fix comparison operators [ruby-core:26646]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@26093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 12 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 14 insertions, 4 deletions
@@ -1,3 +1,7 @@ +Mon Dec 14 12:53:56 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca> + + * lib/bigdecimal.rb: fix comparison operators [ruby-core:26646] + Mon Dec 14 12:40:10 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca> * object.c (rb_Float): Allow results of to_f to be NaN diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 21b7d8d68d..317b171548 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -734,15 +734,21 @@ BigDecimalCmp(VALUE self, VALUE r,char op) Real *a, *b; GUARD_OBJ(a,GetVpValue(self,1)); b = GetVpValue(r,0); - if(!b) return rb_num_coerce_cmp(self,r); + if(!b) { + switch(op) + { + case '*': return rb_num_coerce_cmp(self,r); /* any op */ + case '=': return RTEST(rb_num_coerce_cmp(self,r)) ? Qtrue : Qfalse; + default: return rb_num_coerce_relop(self,r); + } + } SAVE(b); e = VpComp(a, b); - if(e==999) return Qnil; + if(e==999) return (op == '*') ? Qnil : Qfalse; switch(op) { case '*': return INT2FIX(e); /* any op */ case '=': if(e==0) return Qtrue ; return Qfalse; - case '!': if(e!=0) return Qtrue ; return Qfalse; case 'G': if(e>=0) return Qtrue ; return Qfalse; case '>': if(e> 0) return Qtrue ; return Qfalse; case 'L': if(e<=0) return Qtrue ; return Qfalse; @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2009-12-14" #define RUBY_VERSION_CODE 187 #define RUBY_RELEASE_CODE 20091214 -#define RUBY_PATCHLEVEL 236 +#define RUBY_PATCHLEVEL 237 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 |