diff options
author | Jeremy Evans <code@jeremyevans.net> | 2021-07-26 11:20:27 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2021-08-06 15:03:51 -0700 |
commit | d16b68cb2204eeb5af8bd39149202b630374c67f (patch) | |
tree | d14b41ad62a2ef2a5b2fc40f3917ffebf83d2d80 /internal/rational.h | |
parent | 0d3520b063b304708699d3b7ea82b0a5b0279555 (diff) | |
download | ruby-d16b68cb2204eeb5af8bd39149202b630374c67f.tar.gz |
Use Rational for Float#round with ndigits > 14
ndigits higher than 14 can result in values that are slightly too
large due to floating point limitations. Converting to rational
for the calculation and then back to float fixes these issues.
Fixes [Bug #14635]
Fixes [Bug #17183]
Co-authored by: Yusuke Endoh <mame@ruby-lang.org>
Diffstat (limited to 'internal/rational.h')
-rw-r--r-- | internal/rational.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/internal/rational.h b/internal/rational.h index 6bbd2a9810..a9e96742c9 100644 --- a/internal/rational.h +++ b/internal/rational.h @@ -39,6 +39,7 @@ VALUE rb_rational_cmp(VALUE self, VALUE other); VALUE rb_rational_pow(VALUE self, VALUE other); VALUE rb_rational_floor(VALUE self, int ndigits); VALUE rb_numeric_quo(VALUE x, VALUE y); +VALUE rb_flo_round_by_rational(int argc, VALUE *argv, VALUE num); VALUE rb_float_numerator(VALUE x); VALUE rb_float_denominator(VALUE x); |