double rb_big2dbl(VALUE obj) { NativeMethodEnvironment* env = NativeMethodEnvironment::get(); Bignum* big = c_as<Bignum>(env->get_object(obj)); double d = big->to_double(env->state()); if(std::isinf(d)) { rb_warn("Bignum out of Float range"); d = HUGE_VAL; } return d; }
double rb_big2dbl(VALUE obj) { NativeMethodEnvironment* env = NativeMethodEnvironment::get(); Bignum* big = c_as<Bignum>(env->get_object(obj)); double d = big->to_double(env->state()); if(isinf(d)) { rb_warn("Bignum out of Float range"); if(big->mp_val()->sign == MP_NEG) { d = -HUGE_VAL; } else { d = HUGE_VAL; } } return d; }