rem

abstract operator fun rem(divisor: BigDecimal): BigDecimal

Returns a BigDecimal whose value is (this % divisor).

The remainder is given by this.minus(this.divideToIntegralValue(divisor).timesLong(divisor)). Note that this is not the modulo operation (the result can be negative).

Return

this % divisor.

Since

1.5

Parameters

divisor

value by which this BigDecimal is to be divided.

Throws

if divisor==0


abstract fun rem(divisor: BigDecimal, mc: MathContext): BigDecimal

Returns a BigDecimal whose value is (this % divisor), with rounding according to the context settings. The MathContext settings affect the implicit div used to compute the remainder. The remainder computation itself is by definition exact. Therefore, the remainder may contain more than mc.getPrecision() digits.

The remainder is given by this.minus(this.divideToIntegralValue(divisor, mc).timesLong(divisor)). Note that this is not the modulo operation (the result can be negative).

Return

this % divisor, rounded as necessary.

Since

1.5

Parameters

divisor

value by which this BigDecimal is to be divided.

mc

the context to use.

See also

.divideToIntegralValue

Throws

if the result is inexact but the rounding mode is UNNECESSARY, or mc._precision> 0 and the result of this.divideToIntgralValue(divisor) would require a _precision of more than mc._precision digits.