| 148 | } |
| 149 | |
| 150 | public Precise reduce() { |
| 151 | String str = this.integer.toString(); |
| 152 | int start = str.length() - 1; |
| 153 | if (start == 0) { |
| 154 | if (str.equals("0")) { |
| 155 | this.decimals = 0; |
| 156 | } |
| 157 | return this; |
| 158 | } |
| 159 | int i; |
| 160 | for (i = start; i >= 0; i--) { |
| 161 | if (str.charAt(i) != '0') { |
| 162 | break; |
| 163 | } |
| 164 | } |
| 165 | int difference = start - i; |
| 166 | if (difference == 0) { |
| 167 | return this; |
| 168 | } |
| 169 | this.decimals = toInt(this.decimals) - difference; |
| 170 | this.integer = new BigInteger(str.substring(0, i + 1)); |
| 171 | return this; |
| 172 | } |
| 173 | |
| 174 | public boolean equals(Precise other) { |
| 175 | this.reduce(); |