src/bignum-gem.c
static mrb_value
float_to_int(mrb_state *mrb, mrb_value self, mrb_bool fixnum_conv)
{
  mrb_float fltself = mrb_float(self);
  mpz_t num;
  mrb_value out;

  if (isnan(fltself)) {
    mrb_raise(mrb, E_FLOATDOMAIN_ERROR, "NaN");
  }
  if (isinf(fltself)) {
    mrb_raise(mrb, E_FLOATDOMAIN_ERROR, fltself < 0 ? "-Infinity" : "Infinity");
  }

  F(modf)(fltself, &fltself);
  mpz_init_set_d(num, fltself);
  out = new_bignum(mrb, num, FIXNUM_CONVERT);
  mpz_clear(num);
  return out;
}
/* Convert a Float to Bignum or Fixnum */
Convert a Float to Bignum or Fixnum
Convert a Float to Bignum or Fixnum
static mrb_value
float_to_int(mrb_state *mrb, mrb_value self, mrb_bool fixnum_conv)
{
  mrb_float fltself = mrb_float(self);
  mpz_t num;
  mrb_value out;
  if (isnan(fltself)) {
    mrb_raise(mrb, E_FLOATDOMAIN_ERROR, "NaN");
  }
  if (isinf(fltself)) {
    mrb_raise(mrb, E_FLOATDOMAIN_ERROR, fltself < 0 ? "-Infinity" : "Infinity");
  }
  F(modf)(fltself, &fltself);
  mpz_init_set_d(num, fltself);
  out = new_bignum(mrb, num, FIXNUM_CONVERT);
  mpz_clear(num);
  return out;
}
static mrb_value float_to_int ( mrb_state * mrb , mrb_value self , mrb_bool fixnum_conv ) { mrb_float fltself = mrb_float ( self ) ; mpz_t num ; mrb_value out ; if ( isnan ( fltself ) ) { mrb_raise ( mrb , E_FLOATDOMAIN_ERROR , " " ) ; } if ( isinf ( fltself ) ) { mrb_raise ( mrb , E_FLOATDOMAIN_ERROR , fltself < 0 ? " " : " " ) ; } F ( modf ) ( fltself , & fltself ) ; mpz_init_set_d ( num , fltself ) ; out = new_bignum ( mrb , num , FIXNUM_CONVERT ) ; mpz_clear ( num ) ; return out ; }
Convert a Float to Bignum or Fixnum
Convert a Float to Bignum or Fixnum