Method deprecated or moved
This method is deprecated or moved on the latest stable version.
The last existing version (v1_8_7_330) is shown here.
These similar methods exist in v2_5_5:
quo(p1)
public
Returns the floating point result of dividing big by
numeric.
-1234567890987654321.quo(13731)
-1234567890987654321.quo(13731.24)
Show source
/*
* call-seq:
* big.quo(numeric) -> float
* big.fdiv(numeric) -> float
*
* Returns the floating point result of dividing <i>big</i> by
* <i>numeric</i>.
*
* -1234567890987654321.quo(13731) #=> -89910996357705.5
* -1234567890987654321.quo(13731.24) #=> -89909424858035.7
*
*/
static VALUE
rb_big_quo(x, y)
VALUE x, y;
{
double dx = big2dbl(x);
double dy;
if (isinf(dx)) {
VALUE z;
int ex, ey;
ex = (RBIGNUM(bigtrunc(x))->len - 1) * BITSPERDIG;
ex += bdigbitsize(BDIGITS(x)[RBIGNUM(x)->len - 1]);
ex -= 2 * DBL_BIGDIG * BITSPERDIG;
if (ex) x = big_shift(x, ex);
switch (TYPE(y)) {
case T_FIXNUM:
y = rb_int2big(FIX2LONG(y));
case T_BIGNUM: {
ey = (RBIGNUM(bigtrunc(y))->len - 1) * BITSPERDIG;
ey += bdigbitsize(BDIGITS(y)[RBIGNUM(y)->len - 1]);
ey -= DBL_BIGDIG * BITSPERDIG;
if (ey) y = big_shift(y, ey);
bignum:
bigdivrem(x, y, &z, 0);
return rb_float_new(ldexp(big2dbl(z), ex - ey));
}
case T_FLOAT:
y = dbl2big(ldexp(frexp(RFLOAT(y)->value, &ey), DBL_MANT_DIG));
ey -= DBL_MANT_DIG;
goto bignum;
}
}
switch (TYPE(y)) {
case T_FIXNUM:
dy = (double)FIX2LONG(y);
break;
case T_BIGNUM:
dy = rb_big2dbl(y);
break;
case T_FLOAT:
dy = RFLOAT(y)->value;
break;
default:
return rb_num_coerce_bin(x, y);
}
return rb_float_new(dx / dy);
}