mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-30 23:02:15 +00:00
Fix my previous buggy commit that changed Utils.bitcoinValueToFriendlyString
This commit is contained in:
parent
d268270d7b
commit
dd9e0d5d0d
@ -304,9 +304,10 @@ public class Utils {
|
||||
value = value.negate();
|
||||
BigDecimal bd = new BigDecimal(value, 8);
|
||||
String formatted = bd.toPlainString(); // Don't use scientific notation.
|
||||
int decimalPoint = formatted.indexOf(".");
|
||||
// Drop unnecessary zeros from the end.
|
||||
int toDelete = 0;
|
||||
for (int i = formatted.length() - 1; i > 1; i--) {
|
||||
for (int i = formatted.length() - 1; i > decimalPoint + 2; i--) {
|
||||
if (formatted.charAt(i) == '0')
|
||||
toDelete++;
|
||||
else
|
||||
|
@ -50,6 +50,7 @@ public class UtilsTest {
|
||||
|
||||
@Test
|
||||
public void testFormatting() {
|
||||
assertEquals("1.00", bitcoinValueToFriendlyString(toNanoCoins(1, 0)));
|
||||
assertEquals("1.23", bitcoinValueToFriendlyString(toNanoCoins(1, 23)));
|
||||
assertEquals("0.001", bitcoinValueToFriendlyString(BigInteger.valueOf(COIN.longValue() / 1000)));
|
||||
assertEquals("-1.23", bitcoinValueToFriendlyString(toNanoCoins(1, 23).negate()));
|
||||
|
Loading…
Reference in New Issue
Block a user