mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ratioanl.c (float_rationalize): reduced.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
985fe77356
commit
81af1bd9e8
2 changed files with 22 additions and 10 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sat Dec 15 18:00:00 2012 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
|
* ratioanl.c (float_rationalize): reduced.
|
||||||
|
|
||||||
Sat Dec 15 14:18:44 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Sat Dec 15 14:18:44 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* io.c (finish_writeconv): uses rb_write_internal2 if
|
* io.c (finish_writeconv): uses rb_write_internal2 if
|
||||||
|
|
28
rational.c
28
rational.c
|
@ -1935,17 +1935,25 @@ float_rationalize(int argc, VALUE *argv, VALUE self)
|
||||||
return rb_rational_new1(f_lshift(f, n));
|
return rb_rational_new1(f_lshift(f, n));
|
||||||
|
|
||||||
#if FLT_RADIX == 2
|
#if FLT_RADIX == 2
|
||||||
a = rb_rational_new2(f_sub(f_mul(TWO, f), ONE),
|
{
|
||||||
f_lshift(ONE, f_sub(ONE, n)));
|
VALUE two_times_f, den;
|
||||||
b = rb_rational_new2(f_add(f_mul(TWO, f), ONE),
|
|
||||||
f_lshift(ONE, f_sub(ONE, n)));
|
two_times_f = f_mul(TWO, f);
|
||||||
|
den = f_lshift(ONE, f_sub(ONE, n));
|
||||||
|
|
||||||
|
a = rb_rational_new2(f_sub(two_times_f, ONE), den);
|
||||||
|
b = rb_rational_new2(f_add(two_times_f, ONE), den);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
a = rb_rational_new2(f_sub(f_mul(INT2FIX(FLT_RADIX), f),
|
{
|
||||||
INT2FIX(FLT_RADIX - 1)),
|
VALUE radix_times_f, den;
|
||||||
f_expt(INT2FIX(FLT_RADIX), f_sub(ONE, n)));
|
|
||||||
b = rb_rational_new2(f_add(f_mul(INT2FIX(FLT_RADIX), f),
|
radix_times_f = f_mul(INT2FIX(FLT_RADIX), f);
|
||||||
INT2FIX(FLT_RADIX - 1)),
|
den = f_expt(INT2FIX(FLT_RADIX), f_sub(ONE, n));
|
||||||
f_expt(INT2FIX(FLT_RADIX), f_sub(ONE, n)));
|
|
||||||
|
a = rb_rational_new2(f_sub(radix_times_f, INT2FIX(FLT_RADIX - 1)), den);
|
||||||
|
b = rb_rational_new2(f_add(radix_times_f, INT2FIX(FLT_RADIX - 1)), den);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue