summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-05 09:36:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-05 09:36:39 +0000
commit9b52ae2e6491bb5d6c59e1799449f6268baf6f89 ()
treea3020e451c67ff06e2b90ad94402e9fc03e2dac1
parente691ba3baca5883a052d062df7c5d671c384ed0c (diff)
* numeric.c (flo_to_s): keeps enough precision for round trip.
[ruby-core:22325] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--numeric.c8
2 files changed, 10 insertions, 3 deletions
@@ -1,3 +1,8 @@
Thu Mar 5 16:56:14 2009 Nobuyoshi Nakada <[email protected]>
* lib/tmpdir.rb (Dir.tmpdir): not use USERPROFILE, and ignores
@@ -521,7 +521,9 @@ rb_float_new(double d)
static VALUE
flo_to_s(VALUE flt)
{
- char buf[32];
double value = RFLOAT_VALUE(flt);
char *p, *e;
@@ -530,12 +532,12 @@ flo_to_s(VALUE flt)
else if(isnan(value))
return rb_usascii_str_new2("NaN");
- snprintf(buf, sizeof(buf), "%#.15g", value); /* ensure to print decimal point */
if (!(e = strchr(buf, 'e'))) {
e = buf + strlen(buf);
}
if (!ISDIGIT(e[-1])) { /* reformat if ended with decimal point (ex 111111111111111.) */
- snprintf(buf, sizeof(buf), "%#.14e", value);
if (!(e = strchr(buf, 'e'))) {
e = buf + strlen(buf);
}