mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-13 10:45:51 +00:00
remove some calls to BigDecimal#setScale where return objects are not used
- setScale is called on immutable BigDecimal - the returned new BigDecimal is not assigned
This commit is contained in:
parent
ce50e0b755
commit
2209b9b734
@ -142,17 +142,14 @@ public final class BtcAutoFormat extends BtcFormat {
|
||||
int coinOffset = Math.max(SMALLEST_UNIT_EXPONENT - fractionPlaces, 0);
|
||||
BigDecimal inCoins = new BigDecimal(satoshis).movePointLeft(coinOffset);
|
||||
if (inCoins.remainder(ONE).compareTo(ZERO) == 0) {
|
||||
inCoins.setScale(0);
|
||||
places = COIN_SCALE;
|
||||
} else {
|
||||
BigDecimal inMillis = inCoins.movePointRight(MILLICOIN_SCALE);
|
||||
if (inMillis.remainder(ONE).compareTo(ZERO) == 0) {
|
||||
inMillis.setScale(0);
|
||||
places = MILLICOIN_SCALE;
|
||||
} else {
|
||||
BigDecimal inMicros = inCoins.movePointRight(MICROCOIN_SCALE);
|
||||
if (inMicros.remainder(ONE).compareTo(ZERO) == 0) {
|
||||
inMicros.setScale(0);
|
||||
places = MICROCOIN_SCALE;
|
||||
} else {
|
||||
// no way to avoid rounding: so what denomination gives smallest error?
|
||||
|
Loading…
x
Reference in New Issue
Block a user