summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-26 11:48:21 (GMT)
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-26 11:48:21 (GMT)
commit092c647cb70af77b431f00c83126f93b0364857b (patch)
treed0587f0fd11b2a042fb699d28cbf366a6441141c /time.c
parentfebf2cefb3b69dd859b3c81e0512d0bae9b315ea (diff)
* time.c (rb_time_unmagnify_to_float): Avoid double rounding.
Reported by Tsuyoshi Sawada. https://bugs.ruby-lang.org/issues/10135#note-1 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/time.c b/time.c
index 7ba83bb..6248a74 100644
--- a/time.c
+++ b/time.c
@@ -697,7 +697,10 @@ rb_time_unmagnify_to_float(wideval_t w)
}
#endif
v = w2v(w);
- return quo(v, DBL2NUM(TIME_SCALE));
+ if (RB_TYPE_P(v, T_RATIONAL))
+ return rb_Float(quo(v, INT2FIX(TIME_SCALE)));
+ else
+ return quo(v, DBL2NUM(TIME_SCALE));
}
static void