Parses an amount expressed in the way humans are used to. This takes string in a format understood by BigDecimal#BigDecimal(String), for example "0", "1", "0.10", "1.23E3", "1234.5E-5". @throws IllegalArgumentException if you try to specify fractional satoshis, or a value out of r
(final String currencyCode, String input)
| 89 | * @throws IllegalArgumentException if you try to specify fractional satoshis, or a value out of range. |
| 90 | */ |
| 91 | public static Altcoin parseAltcoin(final String currencyCode, String input) { |
| 92 | String cleaned = ParsingUtils.convertCharsForNumber(input); |
| 93 | try { |
| 94 | long val = new BigDecimal(cleaned).movePointRight(SMALLEST_UNIT_EXPONENT) |
| 95 | .toBigIntegerExact().longValue(); |
| 96 | return Altcoin.valueOf(currencyCode, val); |
| 97 | } catch (ArithmeticException e) { |
| 98 | throw new IllegalArgumentException(e); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | public Altcoin add(final Altcoin value) { |
| 103 | checkArgument(value.currencyCode.equals(currencyCode)); |
no test coverage detected