()
| 178 | } |
| 179 | |
| 180 | @Override |
| 181 | public String toString() { |
| 182 | this.reduce(); |
| 183 | String sign = ""; |
| 184 | BigInteger abs; |
| 185 | if (this.integer.compareTo(BigInteger.ZERO) < 0) { |
| 186 | sign = "-"; |
| 187 | abs = this.integer.negate(); |
| 188 | } else { |
| 189 | abs = this.integer; |
| 190 | } |
| 191 | String absParsed = abs.toString(); |
| 192 | |
| 193 | int padSize = Math.max(toInt(this.decimals), 0); |
| 194 | String padded = leftPad(absParsed, Math.max(padSize, absParsed.length()), '0'); |
| 195 | |
| 196 | List<String> integerArray = new ArrayList<>(padded.length()); |
| 197 | for (int i = 0; i < padded.length(); i++) { |
| 198 | integerArray.add(String.valueOf(padded.charAt(i))); |
| 199 | } |
| 200 | |
| 201 | int index = integerArray.size() - toInt(this.decimals); |
| 202 | |
| 203 | String item; |
| 204 | if (index == 0) { |
| 205 | item = "0."; |
| 206 | } else if (toInt(this.decimals) < 0) { |
| 207 | item = repeat('0', -toInt(this.decimals)); |
| 208 | } else if (toInt(this.decimals) == 0) { |
| 209 | item = ""; |
| 210 | } else { |
| 211 | item = "."; |
| 212 | } |
| 213 | |
| 214 | int arrayIndex = Math.min(index, integerArray.size()); |
| 215 | integerArray.add(arrayIndex, item); |
| 216 | |
| 217 | StringBuilder sb = new StringBuilder(sign); |
| 218 | for (String s : integerArray) sb.append(s); |
| 219 | return sb.toString(); |
| 220 | } |
| 221 | |
| 222 | // -------- static string ops -------- |
| 223 | public static String stringMul(Object string1, Object string2) { |
no test coverage detected