3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-14 19:25:51 +00:00

Monetary: Tiny optimization in parseCoin()/parseFiat().

This commit is contained in:
Andreas Schildbach 2016-10-22 19:14:09 +02:00
parent 1746be6e10
commit 9c72c86ed1
2 changed files with 2 additions and 3 deletions

View File

@ -125,7 +125,7 @@ public final class Coin implements Monetary, Comparable<Coin>, Serializable {
*/
public static Coin parseCoin(final String str) {
try {
long satoshis = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).toBigIntegerExact().longValue();
long satoshis = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValueExact();
return Coin.valueOf(satoshis);
} catch (ArithmeticException e) {
throw new IllegalArgumentException(e); // Repackage exception to honor method contract

View File

@ -84,8 +84,7 @@ public final class Fiat implements Monetary, Comparable<Fiat>, Serializable {
*/
public static Fiat parseFiat(final String currencyCode, final String str) {
try {
long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT)
.toBigIntegerExact().longValue();
long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValueExact();
return Fiat.valueOf(currencyCode, val);
} catch (ArithmeticException e) {
throw new IllegalArgumentException(e);