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:
parent
1746be6e10
commit
9c72c86ed1
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user