aboutsummaryrefslogtreecommitdiffstats
path: root/ext/bigdecimal
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-23 03:30:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-23 03:30:30 +0000
commit4a574f7ad985d7e5d1d1596b7632e4db8620e65b (patch)
treeaf9f00c29a4684b4dc957ee72b1dbd24418c763b /ext/bigdecimal
parentcb2a99822e3260fa664a24d96841e21767b9f50b (diff)
downloadruby-4a574f7ad985d7e5d1d1596b7632e4db8620e65b.tar.gz
bigdecimal.c: fix FloatDomainError
* ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec): consider non-finite float values not to raise FloatDomainError. [ruby-core:75682] [Bug #12414] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 9125e6b585..3ccad9a508 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -239,6 +239,12 @@ again:
if (prec < 0) goto unable_to_coerce_without_prec;
if (prec > DBL_DIG+1) goto SomeOneMayDoIt;
d = RFLOAT_VALUE(v);
+ if (!isfinite(d)) {
+ pv = VpCreateRbObject(prec, NULL);
+ pv->sign = isnan(d) ? VP_SIGN_NaN :
+ d > 0 ? VP_SIGN_POSITIVE_INFINITE : VP_SIGN_NEGATIVE_FINITE;
+ return pv;
+ }
if (d != 0.0) {
v = rb_funcall(v, id_to_r, 0);
goto again;