summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
author(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-04-14 14:35:50 +0000
committer(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-04-14 14:35:50 +0000
commited131ebad88c2948d7b40f93ff6ce39f1eb8a2f7 (patch)
tree7bbf62c5e0d0bb8ff971637cf432c6f16824f8f6 /numeric.c
parentbe1fea072cd0d22788ef8a931c0c6b64a2503b5d (diff)
This commit was manufactured by cvs2svn to create tag 'v1_4_4'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_4_4@668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/numeric.c b/numeric.c
index d1c016e708..b21b17407e 100644
--- a/numeric.c
+++ b/numeric.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Aug 13 18:33:09 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
@@ -43,8 +43,8 @@ num_coerce(x, y)
VALUE x, y;
{
if (CLASS_OF(x) == CLASS_OF(y))
- return rb_assoc_new(x, y);
- return rb_assoc_new(rb_Float(x), rb_Float(y));
+ return rb_assoc_new(y, x);
+ return rb_assoc_new(rb_Float(y), rb_Float(x));
}
static VALUE
@@ -330,8 +330,7 @@ flo_modulo(x, y, modulo)
result = value1 - value2 * value;
}
#endif
- if (modulo &&
- (RFLOAT(x)->value < 0.0) != (result < 0.0) && result != 0.0) {
+ if (modulo && value*result<0.0) {
result += value;
}
return rb_float_new(result);
@@ -1169,12 +1168,10 @@ fix_rshift(x, y)
long i, val;
i = NUM2LONG(y);
- if (i < sizeof(long) * 8) {
- val = RSHIFT(FIX2LONG(x), i);
- return INT2FIX(val);
- }
-
- return INT2FIX(0);
+ if (i < 0)
+ return fix_lshift(x, INT2FIX(-i));
+ val = RSHIFT(FIX2LONG(x), i);
+ return INT2FIX(val);
}
static VALUE