| 91 | } |
| 92 | |
| 93 | public Precise mod(Precise other) { |
| 94 | int rationizerNumerator = Math.max(-toInt(this.decimals) + toInt(other.decimals), 0); |
| 95 | BigInteger numerator = this.integer.multiply(BigInteger.valueOf(this.baseNumber).pow(rationizerNumerator)); |
| 96 | int rationizerDenominator = Math.max(-toInt(other.decimals) + toInt(this.decimals), 0); |
| 97 | BigInteger denominator = other.integer.multiply(BigInteger.valueOf(this.baseNumber).pow(rationizerDenominator)); |
| 98 | BigInteger result = numerator.remainder(denominator); |
| 99 | return new Precise(result.toString(), rationizerDenominator + toInt(other.decimals)); |
| 100 | } |
| 101 | |
| 102 | public Precise sub(Precise other) { |
| 103 | Precise negative = new Precise(other.integer.negate().toString(), other.decimals); |