From 2753f846938e5edfd164de9d1c72d5bce7c593ec Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 19 Aug 2002 05:56:09 +0000 Subject: * array.c (sort_2): *a - *b may overflow. * array.c (ary_new): len*sizeof(VALUE) may be a positive value. * array.c (rb_ary_initialize): ditto. * object.c (rb_class_allocate_instance): move singleton class check from rb_obj_alloc(). * re.c (rb_reg_initialize): should not modify frozen Regexp. * ext/tcltklib/tcltklib.c (ip_init): allocation framework. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- numeric.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index a62f53f74..87d7e986a 100644 --- a/numeric.c +++ b/numeric.c @@ -479,6 +479,16 @@ flo_hash(num) return INT2FIX(hash); } +VALUE +rb_dbl_cmp(a, b) + double a, b; +{ + if (a == b) return INT2FIX(0); + if (a > b) return INT2FIX(1); + if (a < b) return INT2FIX(-1); + rb_raise(rb_eFloatDomainError, "comparing NaN"); +} + static VALUE flo_cmp(x, y) VALUE x, y; @@ -502,10 +512,7 @@ flo_cmp(x, y) default: return rb_num_coerce_bin(x, y); } - if (a == b) return INT2FIX(0); - if (a > b) return INT2FIX(1); - if (a < b) return INT2FIX(-1); - rb_raise(rb_eFloatDomainError, "comparing NaN"); + return rb_dbl_cmp(a, b); } static VALUE -- cgit