summaryrefslogtreecommitdiffstats
path: root/complex.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-30 14:50:55 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-30 14:50:55 +0000
commit8c20f66c485649560ed6082233dbe03cdcdaf7a3 (patch)
treec2da11a0d90c4625c04880075baa333a44835aae /complex.c
parent2236e5982240d81789400d045a4d8423eb33d090 (diff)
downloadruby-8c20f66c485649560ed6082233dbe03cdcdaf7a3.tar.gz
ruby-8c20f66c485649560ed6082233dbe03cdcdaf7a3.tar.xz
ruby-8c20f66c485649560ed6082233dbe03cdcdaf7a3.zip
* proc.c (proc_dup): should copy is_lambda attribute as well.
[ruby-talk:296244] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/complex.c b/complex.c
index 164474636..58704110c 100644
--- a/complex.c
+++ b/complex.c
@@ -85,22 +85,6 @@ f_add(VALUE x, VALUE y)
}
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)
{
VALUE r;
@@ -200,6 +184,22 @@ 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,13 +1016,22 @@ nucomp_inexact_p(VALUE self)
return f_boolcast(!nucomp_exact_p(self));
}
-extern VALUE rb_lcm(VALUE x, VALUE y);
+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));
+}
static VALUE
nucomp_denominator(VALUE self)
{
get_dat1(self);
- return rb_lcm(f_denominator(dat->real), f_denominator(dat->image));
+ return f_lcm(f_denominator(dat->real), f_denominator(dat->image));
}
static VALUE