(Precise other)
| 69 | } |
| 70 | |
| 71 | public Precise add(Precise other) { |
| 72 | if (this.decimals == other.decimals) { |
| 73 | BigInteger integerResult = this.integer.add(other.integer); |
| 74 | return new Precise(integerResult.toString(), this.decimals); |
| 75 | } else { |
| 76 | Precise smaller; |
| 77 | Precise bigger; |
| 78 | if (toInt(this.decimals) < toInt(other.decimals)) { |
| 79 | smaller = this; |
| 80 | bigger = other; |
| 81 | } else { |
| 82 | smaller = other; |
| 83 | bigger = this; |
| 84 | } |
| 85 | int exponent = toInt(bigger.decimals) - toInt(smaller.decimals); |
| 86 | BigInteger factor = BigInteger.valueOf(baseNumber).pow(exponent); |
| 87 | BigInteger normalized = smaller.integer.multiply(factor); |
| 88 | BigInteger result = normalized.add(bigger.integer); |
| 89 | return new Precise(result.toString(), bigger.decimals); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | public Precise mod(Precise other) { |
| 94 | int rationizerNumerator = Math.max(-toInt(this.decimals) + toInt(other.decimals), 0); |
no test coverage detected