mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
numeric.c: remove duplicate code
* numeric.c (flo_to_i): use dbl2ival and reduce duplicate code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
081b38fd48
commit
015d05c6e6
1 changed files with 1 additions and 6 deletions
|
@ -2324,16 +2324,11 @@ static VALUE
|
|||
flo_to_i(VALUE num)
|
||||
{
|
||||
double f = RFLOAT_VALUE(num);
|
||||
long val;
|
||||
|
||||
if (f > 0.0) f = floor(f);
|
||||
if (f < 0.0) f = ceil(f);
|
||||
|
||||
if (!FIXABLE(f)) {
|
||||
return rb_dbl2big(f);
|
||||
}
|
||||
val = (long)f;
|
||||
return LONG2FIX(val);
|
||||
return dbl2ival(f);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue