diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-30 03:22:23 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-30 03:22:23 +0000 |
commit | caa3c880400e48ff22099f3c003e6ba5290f9b61 (patch) | |
tree | 8ea6753ed959e208591a98766cd517736b05cdc7 /time.c | |
parent | adcab6c1bb711ba5f5b53073bdcb571ce28d26a2 (diff) | |
download | ruby-caa3c880400e48ff22099f3c003e6ba5290f9b61.tar.gz |
* time.c (v2w): Normalize a rational value to an integer if possible.
[ruby-core:58070] [Bug #9059] reported by Isaac Schwabacher.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -320,6 +320,11 @@ v2w_bignum(VALUE v) static inline wideval_t v2w(VALUE v) { + if (RB_TYPE_P(v, T_RATIONAL)) { + if (RRATIONAL(v)->den != LONG2FIX(1)) + return v; + v = RRATIONAL(v)->num; + } #if WIDEVALUE_IS_WIDER if (FIXNUM_P(v)) { return WIDEVAL_WRAP((WIDEVALUE)(SIGNED_WIDEVALUE)(long)v); |