method
quo
v2_6_3 -
Show latest stable
- Class:
BigDecimal
quo(p1)public
Divide by the specified value.
See BigDecimal#div.
static VALUE
BigDecimal_div(VALUE self, VALUE r)
/* For c = self/r: with round operation */
{
ENTER(5);
Real *c=NULL, *res=NULL, *div = NULL;
r = BigDecimal_divide(&c, &res, &div, self, r);
if (!NIL_P(r)) return r; /* coerced by other */
SAVE(c); SAVE(res); SAVE(div);
/* a/b = c + r/b */
/* c xxxxx
r 00000yyyyy ==> (y/b)*BASE >= HALF_BASE
*/
/* Round */
if (VpHasVal(div)) { /* frac[0] must be zero for NaN,INF,Zero */
VpInternalRound(c, 0, c->frac[c->Prec-1], (BDIGIT)(VpBaseVal() * (BDIGIT_DBL)res->frac[0] / div->frac[0]));
}
return ToValue(c);
} Related methods
- Instance methods
- %
- *
- **
- +
- +@
- -
- -@
- /
- <
- <=
- <=>
- ==
- ===
- >
- >=
- _dump
- abs
- add
- as_json
- ceil
- clone
- coerce
- div
- divmod
- dup
- eql?
- exponent
- finite?
- fix
- floor
- frac
- hash
- infinite?
- initialize_copy
- inspect
- modulo
- mult
- nan?
- nonzero?
- power
- precs
- quo
- remainder
- round
- sign
- split
- sqrt
- sub
- to_d
- to_digits
- to_f
- to_i
- to_int
- to_json
- to_r
- to_s
- truncate
- zero?
- Class methods
- _load
- double_fig
- json_create
- limit
- mode
- new
- save_exception_mode
- save_limit
- save_rounding_mode