diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-23 03:30:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-23 03:30:30 +0000 |
commit | 172abd7255d26766c1fb78e7d8ee70ce314b7e2f (patch) | |
tree | af9f00c29a4684b4dc957ee72b1dbd24418c763b /ext/bigdecimal/bigdecimal.c | |
parent | aab987fdc40171215912e3ce14f0d293f2be4221 (diff) | |
download | ruby-172abd7255d26766c1fb78e7d8ee70ce314b7e2f.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/bigdecimal.c')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 6 |
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; |