Skip to content

Commit

Permalink
* numeric.c (flo_eq): remove unnecessary NaN check using isnan().
Browse files Browse the repository at this point in the history
  comparison regarding NaN is false anyway.

* numeric.c (flo_gt, flo_ge, flo_lt, flo_le, flo_eql): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Feb 23, 2009
1 parent c43236e commit 60e8b39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Tue Feb 24 01:53:40 2009 Yukihiro Matsumoto <matz@ruby-lang.org>

* numeric.c (flo_eq): remove unnecessary NaN check using isnan().
comparison regarding NaN is false anyway.

* numeric.c (flo_gt, flo_ge, flo_lt, flo_le, flo_eql): ditto.

Tue Feb 24 01:22:19 2009 Yusuke Endoh <mame@tsg.ne.jp>

* bootstraptest/test_thread.rb: fix for environment where fork is not
Expand Down
17 changes: 2 additions & 15 deletions numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,13 +874,11 @@ flo_eq(VALUE x, VALUE y)
break;
case T_FLOAT:
b = RFLOAT_VALUE(y);
if (isnan(b)) return Qfalse;
break;
default:
return num_equal(x, y);
}
a = RFLOAT_VALUE(x);
if (isnan(a)) return Qfalse;
return (a == b)?Qtrue:Qfalse;
}

Expand Down Expand Up @@ -970,13 +968,11 @@ flo_gt(VALUE x, VALUE y)

case T_FLOAT:
b = RFLOAT_VALUE(y);
if (isnan(b)) return Qfalse;
break;

default:
return rb_num_coerce_relop(x, y, '>');
}
if (isnan(a)) return Qfalse;
return (a > b)?Qtrue:Qfalse;
}

Expand Down Expand Up @@ -1005,13 +1001,11 @@ flo_ge(VALUE x, VALUE y)

case T_FLOAT:
b = RFLOAT_VALUE(y);
if (isnan(b)) return Qfalse;
break;

default:
return rb_num_coerce_relop(x, y, rb_intern(">="));
}
if (isnan(a)) return Qfalse;
return (a >= b)?Qtrue:Qfalse;
}

Expand Down Expand Up @@ -1039,13 +1033,11 @@ flo_lt(VALUE x, VALUE y)

case T_FLOAT:
b = RFLOAT_VALUE(y);
if (isnan(b)) return Qfalse;
break;

default:
return rb_num_coerce_relop(x, y, '<');
}
if (isnan(a)) return Qfalse;
return (a < b)?Qtrue:Qfalse;
}

Expand Down Expand Up @@ -1074,13 +1066,11 @@ flo_le(VALUE x, VALUE y)

case T_FLOAT:
b = RFLOAT_VALUE(y);
if (isnan(b)) return Qfalse;
break;

default:
return rb_num_coerce_relop(x, y, rb_intern("<="));
}
if (isnan(a)) return Qfalse;
return (a <= b)?Qtrue:Qfalse;
}

Expand All @@ -1099,11 +1089,8 @@ static VALUE
flo_eql(VALUE x, VALUE y)
{
if (TYPE(y) == T_FLOAT) {
double a = RFLOAT_VALUE(x);
double b = RFLOAT_VALUE(y);

if (isnan(a) || isnan(b)) return Qfalse;
if (a == b) return Qtrue;
if (RFLOAT_VALUE(x) == RFLOAT_VALUE(y))
return Qtrue;
}
return Qfalse;
}
Expand Down

0 comments on commit 60e8b39

Please sign in to comment.