diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-07 04:14:57 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-07 04:14:57 +0000 |
commit | fa161103263f001ba009cecfbc25ed336757ede7 (patch) | |
tree | 0677b0d96fbcc241b80054a32859f4c8131438c5 /bignum.c | |
parent | f7b3f1c528260e50db430a0dcd3678d447308d89 (diff) | |
download | ruby-fa161103263f001ba009cecfbc25ed336757ede7.tar.gz |
* bignum.c (rb_big_fdiv): flo.fdiv(NaN) should result NaN.
* numeric.c (num_quo): renamed and moved from bignum.c.
[ruby-dev:34582]
* bignum.c (rb_big_fdiv): update RDoc description
* rational.c (nurat_s_new_m): small refactoring.
* bignum.c (rb_big2dbl): no need for forceful warning when
converting to float. overflow is a nature of float values.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -1219,7 +1219,7 @@ rb_big2dbl(VALUE x) double d = big2dbl(x); if (isinf(d)) { - rb_warn("Bignum out of Float range"); + rb_warning("Bignum out of Float range"); d = HUGE_VAL; } return d; @@ -1975,24 +1975,17 @@ static VALUE big_shift(VALUE x, int n) /* * call-seq: - * big.quo(numeric) -> float - * big.fdiv(numeric) -> float + * big.fdiv(numeric) -> float * * Returns the floating point result of dividing <i>big</i> by * <i>numeric</i>. * - * -1234567890987654321.quo(13731) #=> -89910996357705.5 - * -1234567890987654321.quo(13731.24) #=> -89909424858035.7 + * -1234567890987654321.fdiv(13731) #=> -89910996357705.5 + * -1234567890987654321.fdiv(13731.24) #=> -89909424858035.7 * */ static VALUE -rb_big_quo(VALUE x, VALUE y) -{ - return rb_funcall(rb_rational_raw1(x), '/', 1, rb_Rational1(y)); -} - -static VALUE rb_big_fdiv(VALUE x, VALUE y) { double dx = big2dbl(x); @@ -2021,6 +2014,7 @@ rb_big_fdiv(VALUE x, VALUE y) return DOUBLE2NUM(ldexp(big2dbl(z), ex - ey)); } case T_FLOAT: + if (isnan(RFLOAT_VALUE(y))) return y; y = dbl2big(ldexp(frexp(RFLOAT_VALUE(y), &ey), DBL_MANT_DIG)); ey -= DBL_MANT_DIG; goto bignum; @@ -2688,7 +2682,6 @@ Init_Bignum(void) rb_define_method(rb_cBignum, "divmod", rb_big_divmod, 1); rb_define_method(rb_cBignum, "modulo", rb_big_modulo, 1); rb_define_method(rb_cBignum, "remainder", rb_big_remainder, 1); - rb_define_method(rb_cBignum, "quo", rb_big_quo, 1); rb_define_method(rb_cBignum, "fdiv", rb_big_fdiv, 1); rb_define_method(rb_cBignum, "**", rb_big_pow, 1); rb_define_method(rb_cBignum, "&", rb_big_and, 1); |