0.0.to_s

From: Jeff Mitchell <quixoticsycophant@...>
Date: 2004-05-17 05:45:58 UTC
List: ruby-core #2889
> ruby -e 'puts 0.0'
0.0e+00

I noticed the == 0.0 case was removed.  By oversight or design?

Index: numeric.c
===================================================================
RCS file: /src/ruby/numeric.c,v
retrieving revision 1.108
diff -u -r1.108 numeric.c
--- numeric.c   10 May 2004 08:23:13 -0000      1.108
+++ numeric.c   17 May 2004 05:40:38 -0000
@@ -501,7 +501,10 @@
        return rb_str_new2("NaN");
 
     avalue = fabs(value);
-    if (avalue < 1.0e-7 || avalue >= 1.0e15) {
+    if (avalue == 0.0) {
+       fmt = "%.1f";
+    }
+    else if (avalue < 1.0e-7 || avalue >= 1.0e15) {
        fmt = "%.15e";
     }    
     sprintf(buf, fmt, value);



	
		
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/

In This Thread

Prev Next