mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* complex.c (f_lcm): removed.
* rational.c (rb_lcm, rb_gcdlcm): added. * lib/complex.rb (gcd, lcm, gcdlcm): removed. * lib/rational.rb (gcd, lcm, gcdlcm): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
69ad92d9ca
commit
d4f5cb67d4
5 changed files with 101 additions and 113 deletions
45
complex.c
45
complex.c
|
@ -84,6 +84,22 @@ f_add(VALUE x, VALUE y)
|
|||
return r;
|
||||
}
|
||||
|
||||
inline static VALUE
|
||||
f_cmp(VALUE x, VALUE y)
|
||||
{
|
||||
VALUE r;
|
||||
if (FIXNUM_P(x) && FIXNUM_P(y)) {
|
||||
long c = FIX2LONG(x) - FIX2LONG(y);
|
||||
if (c > 0)
|
||||
c = 1;
|
||||
else if (c < 0)
|
||||
c = -1;
|
||||
r = INT2FIX(c);
|
||||
} else
|
||||
r = rb_funcall(x, id_cmp, 1, y);
|
||||
return r;
|
||||
}
|
||||
|
||||
inline static VALUE
|
||||
f_div(VALUE x, VALUE y)
|
||||
{
|
||||
|
@ -184,22 +200,6 @@ fun1(to_r)
|
|||
fun1(to_s)
|
||||
fun1(truncate)
|
||||
|
||||
inline static VALUE
|
||||
f_cmp(VALUE x, VALUE y)
|
||||
{
|
||||
VALUE r;
|
||||
if (FIXNUM_P(x) && FIXNUM_P(y)) {
|
||||
long c = FIX2LONG(x) - FIX2LONG(y);
|
||||
if (c > 0)
|
||||
c = 1;
|
||||
else if (c < 0)
|
||||
c = -1;
|
||||
r = INT2FIX(c);
|
||||
} else
|
||||
r = rb_funcall(x, id_cmp, 1, y);
|
||||
return r;
|
||||
}
|
||||
|
||||
fun2(coerce)
|
||||
fun2(divmod)
|
||||
|
||||
|
@ -1016,22 +1016,13 @@ nucomp_inexact_p(VALUE self)
|
|||
return f_boolcast(!nucomp_exact_p(self));
|
||||
}
|
||||
|
||||
extern VALUE rb_gcd(VALUE x, VALUE y);
|
||||
|
||||
static VALUE
|
||||
f_lcm(VALUE x, VALUE y)
|
||||
{
|
||||
if (f_zero_p(x) || f_zero_p(y))
|
||||
return ZERO;
|
||||
else
|
||||
return f_abs(f_mul(f_div(x, rb_gcd(x, y)), y));
|
||||
}
|
||||
extern VALUE rb_lcm(VALUE x, VALUE y);
|
||||
|
||||
static VALUE
|
||||
nucomp_denominator(VALUE self)
|
||||
{
|
||||
get_dat1(self);
|
||||
return f_lcm(f_denominator(dat->real), f_denominator(dat->image));
|
||||
return rb_lcm(f_denominator(dat->real), f_denominator(dat->image));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue