ruby-changes:14211
From: marcandre <ko1@a...>
Date: Mon, 7 Dec 2009 07:06:04 +0900 (JST)
Subject: [ruby-changes:14211] Ruby:r26033 (ruby_1_8): * lib/bigdecimal.rb: fix comparison operators
marcandre 2009-12-07 07:05:52 +0900 (Mon, 07 Dec 2009) New Revision: 26033 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26033 Log: * lib/bigdecimal.rb: fix comparison operators [ruby-core:26646] Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/ext/bigdecimal/bigdecimal.c branches/ruby_1_8/test/bigdecimal/test_bigdecimal.rb Index: ruby_1_8/ext/bigdecimal/bigdecimal.c =================================================================== --- ruby_1_8/ext/bigdecimal/bigdecimal.c (revision 26032) +++ ruby_1_8/ext/bigdecimal/bigdecimal.c (revision 26033) @@ -750,15 +750,21 @@ 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; Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 26032) +++ ruby_1_8/ChangeLog (revision 26033) @@ -1,3 +1,7 @@ +Mon Dec 7 07:05:05 2009 Marc-Andre Lafortune <ruby-core@m...> + + * lib/bigdecimal.rb: fix comparison operators [ruby-core:26646] + Mon Dec 7 07:01:19 2009 Marc-Andre Lafortune <ruby-core@m...> * object.c (rb_Float): Allow results of to_f to be NaN Index: ruby_1_8/test/bigdecimal/test_bigdecimal.rb =================================================================== --- ruby_1_8/test/bigdecimal/test_bigdecimal.rb (revision 26032) +++ ruby_1_8/test/bigdecimal/test_bigdecimal.rb (revision 26033) @@ -61,7 +61,6 @@ x = BigDecimal.new("0.1") 100.times do x *= x - break if x == false end end end @@ -71,7 +70,6 @@ x = BigDecimal.new("10") 100.times do x *= x - break if x == false end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/