Commit 470da1ed authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

redefine POST/NEG FIXABLE using INT_MIN/MAX

parent db20b4e0
......@@ -10,10 +10,8 @@
#include <limits.h>
#define RSHIFT(x,y) ((x)>>(int)(y))
#define FIXNUM_MAX (LONG_MAX>>1)
#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
#define POSFIXABLE(f) ((f) < FIXNUM_MAX+1)
#define NEGFIXABLE(f) ((f) >= FIXNUM_MIN)
#define POSFIXABLE(f) ((f) <= INT_MAX)
#define NEGFIXABLE(f) ((f) >= INT_MIN)
#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
mrb_value mrb_flt2big(mrb_state *mrb, mrb_float d);
......
......@@ -565,8 +565,7 @@ mrb_convert_to_integer(mrb_state *mrb, mrb_value val, int base)
switch (mrb_type(val)) {
case MRB_TT_FLOAT:
if (base != 0) goto arg_error;
if (mrb_float(val) <= (double)FIXNUM_MAX
&& mrb_float(val) >= (double)FIXNUM_MIN) {
if (FIXABLE(mrb_float(val))) {
break;
}
return mrb_flt2big(mrb, mrb_float(val));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment