Method: BigDecimal#sub

Defined in:
bigdecimal.c

#sub(b, n) ⇒ Object

sub(value, digits) -> bigdecimal

Subtract the specified value.

e.g.

c = a.sub(b,n)
digits

If specified and less than the number of significant digits of the result, the result is rounded to that number of digits, according to BigDecimal.mode.



2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
# File 'bigdecimal.c', line 2320

static VALUE
BigDecimal_sub2(VALUE self, VALUE b, VALUE n)
{
    ENTER(2);
    Real *cv;
    SIGNED_VALUE mx = check_int_precision(n);
    if (mx == 0) return BigDecimal_sub(self, b);
    else {
	size_t pl = VpSetPrecLimit(0);
	VALUE   c = BigDecimal_sub(self, b);
	VpSetPrecLimit(pl);
	GUARD_OBJ(cv, GetVpValue(c, 1));
	VpLeftRound(cv, VpGetRoundMode(), mx);
        return VpCheckGetValue(cv);
    }
}