Skip to content

Commit

Permalink
* bignum.c (rb_integer_float_cmp): renamed from rb_big_float_cmp.
Browse files Browse the repository at this point in the history
* internal.h: follow the above change.

* numeric.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
akr committed Jul 16, 2012
1 parent 94735e9 commit cf46977
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Mon Jul 16 18:40:26 2012 Tanaka Akira <[email protected]>

* bignum.c (rb_integer_float_cmp): renamed from rb_big_float_cmp.

* internal.h: follow the above change.

* numeric.c: ditto.

Mon Jul 16 17:57:54 2012 Tanaka Akira <[email protected]>

* bignum.c (rb_big_float_cmp): compare an integer and float precisely.
Expand Down
8 changes: 4 additions & 4 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ rb_big_to_f(VALUE x)
}

VALUE
rb_big_float_cmp(VALUE x, VALUE y)
rb_integer_float_cmp(VALUE x, VALUE y)
{
double a = RFLOAT_VALUE(y);
double yi, yf;
Expand Down Expand Up @@ -1506,7 +1506,7 @@ rb_big_cmp(VALUE x, VALUE y)
break;

case T_FLOAT:
return rb_big_float_cmp(x, y);
return rb_integer_float_cmp(x, y);

default:
return rb_num_coerce_cmp(x, y, rb_intern("<=>"));
Expand Down Expand Up @@ -1549,7 +1549,7 @@ big_op(VALUE x, VALUE y, enum big_op_t op)
break;

case T_FLOAT:
rel = rb_big_float_cmp(x, y);
rel = rb_integer_float_cmp(x, y);
break;

default:
Expand Down Expand Up @@ -1654,7 +1654,7 @@ rb_big_eq(VALUE x, VALUE y)
case T_BIGNUM:
break;
case T_FLOAT:
return rb_big_float_cmp(x, y) == INT2FIX(0) ? Qtrue : Qfalse;
return rb_integer_float_cmp(x, y) == INT2FIX(0) ? Qtrue : Qfalse;
default:
return rb_equal(y, x);
}
Expand Down
2 changes: 1 addition & 1 deletion internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ VALUE rb_ary_cat(VALUE, const VALUE *, long);
/* bignum.c */
VALUE rb_big_fdiv(VALUE x, VALUE y);
VALUE rb_big_uminus(VALUE x);
VALUE rb_big_float_cmp(VALUE x, VALUE y);
VALUE rb_integer_float_cmp(VALUE x, VALUE y);

/* class.c */
VALUE rb_obj_methods(int argc, VALUE *argv, VALUE obj);
Expand Down
24 changes: 12 additions & 12 deletions numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ flo_eq(VALUE x, VALUE y)
switch (TYPE(y)) {
case T_FIXNUM:
case T_BIGNUM:
return rb_big_float_cmp(y, x) == INT2FIX(0) ? Qtrue : Qfalse;
return rb_integer_float_cmp(y, x) == INT2FIX(0) ? Qtrue : Qfalse;
case T_FLOAT:
b = RFLOAT_VALUE(y);
#if defined(_MSC_VER) && _MSC_VER < 1300
Expand Down Expand Up @@ -1123,7 +1123,7 @@ flo_cmp(VALUE x, VALUE y)
case T_FIXNUM:
case T_BIGNUM:
{
VALUE rel = rb_big_float_cmp(y, x);
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
return INT2FIX(-FIX2INT(rel));
return rel;
Expand Down Expand Up @@ -1165,7 +1165,7 @@ flo_gt(VALUE x, VALUE y)
case T_FIXNUM:
case T_BIGNUM:
{
VALUE rel = rb_big_float_cmp(y, x);
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
return -FIX2INT(rel) > 0 ? Qtrue : Qfalse;
return Qfalse;
Expand Down Expand Up @@ -1205,7 +1205,7 @@ flo_ge(VALUE x, VALUE y)
case T_FIXNUM:
case T_BIGNUM:
{
VALUE rel = rb_big_float_cmp(y, x);
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
return -FIX2INT(rel) >= 0 ? Qtrue : Qfalse;
return Qfalse;
Expand Down Expand Up @@ -1244,7 +1244,7 @@ flo_lt(VALUE x, VALUE y)
case T_FIXNUM:
case T_BIGNUM:
{
VALUE rel = rb_big_float_cmp(y, x);
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
return -FIX2INT(rel) < 0 ? Qtrue : Qfalse;
return Qfalse;
Expand Down Expand Up @@ -1284,7 +1284,7 @@ flo_le(VALUE x, VALUE y)
case T_FIXNUM:
case T_BIGNUM:
{
VALUE rel = rb_big_float_cmp(y, x);
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
return -FIX2INT(rel) <= 0 ? Qtrue : Qfalse;
return Qfalse;
Expand Down Expand Up @@ -2947,7 +2947,7 @@ fix_equal(VALUE x, VALUE y)
case T_BIGNUM:
return rb_big_eq(y, x);
case T_FLOAT:
return rb_big_float_cmp(x, y) == INT2FIX(0) ? Qtrue : Qfalse;
return rb_integer_float_cmp(x, y) == INT2FIX(0) ? Qtrue : Qfalse;
default:
return num_equal(x, y);
}
Expand Down Expand Up @@ -2975,7 +2975,7 @@ fix_cmp(VALUE x, VALUE y)
case T_BIGNUM:
return rb_big_cmp(rb_int2big(FIX2LONG(x)), y);
case T_FLOAT:
return rb_big_float_cmp(x, y);
return rb_integer_float_cmp(x, y);
default:
return rb_num_coerce_cmp(x, y, rb_intern("<=>"));
}
Expand All @@ -3000,7 +3000,7 @@ fix_gt(VALUE x, VALUE y)
case T_BIGNUM:
return FIX2INT(rb_big_cmp(rb_int2big(FIX2LONG(x)), y)) > 0 ? Qtrue : Qfalse;
case T_FLOAT:
return rb_big_float_cmp(x, y) == INT2FIX(1) ? Qtrue : Qfalse;
return rb_integer_float_cmp(x, y) == INT2FIX(1) ? Qtrue : Qfalse;
default:
return rb_num_coerce_relop(x, y, '>');
}
Expand All @@ -3026,7 +3026,7 @@ fix_ge(VALUE x, VALUE y)
return FIX2INT(rb_big_cmp(rb_int2big(FIX2LONG(x)), y)) >= 0 ? Qtrue : Qfalse;
case T_FLOAT:
{
VALUE rel = rb_big_float_cmp(x, y);
VALUE rel = rb_integer_float_cmp(x, y);
return rel == INT2FIX(1) || rel == INT2FIX(0) ? Qtrue : Qfalse;
}
default:
Expand All @@ -3053,7 +3053,7 @@ fix_lt(VALUE x, VALUE y)
case T_BIGNUM:
return FIX2INT(rb_big_cmp(rb_int2big(FIX2LONG(x)), y)) < 0 ? Qtrue : Qfalse;
case T_FLOAT:
return rb_big_float_cmp(x, y) == INT2FIX(-1) ? Qtrue : Qfalse;
return rb_integer_float_cmp(x, y) == INT2FIX(-1) ? Qtrue : Qfalse;
default:
return rb_num_coerce_relop(x, y, '<');
}
Expand All @@ -3079,7 +3079,7 @@ fix_le(VALUE x, VALUE y)
return FIX2INT(rb_big_cmp(rb_int2big(FIX2LONG(x)), y)) <= 0 ? Qtrue : Qfalse;
case T_FLOAT:
{
VALUE rel = rb_big_float_cmp(x, y);
VALUE rel = rb_integer_float_cmp(x, y);
return rel == INT2FIX(-1) || rel == INT2FIX(0) ? Qtrue : Qfalse;
}
default:
Expand Down

0 comments on commit cf46977

Please sign in to comment.