Remove scientific notation from Bitcoins.toString() (#3811)

This commit is contained in:
benthecarman 2021-11-10 12:55:44 -06:00 committed by GitHub
parent 86bd52d7f2
commit 0b3654f020
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -213,7 +213,7 @@ class CurrencyUnitTest extends BitcoinSUnitTest {
}
}
it must "convert to and from BigDemimals correctly" in {
it must "convert to and from BigDecimals correctly" in {
forAll(CurrencyUnitGenerator.bitcoins) { num =>
assert(Bitcoins(num.toBigDecimal) == num)
}
@ -224,4 +224,9 @@ class CurrencyUnitTest extends BitcoinSUnitTest {
assert(Satoshis.fromHex(num.hex) == num)
}
}
it must "correctly print in Bitcoins.toString" in {
val btc = Bitcoins(12.3456789)
assert(btc.toString == "12.34567890 BTC")
}
}

View file

@ -140,7 +140,9 @@ object Satoshis
sealed abstract class Bitcoins extends CurrencyUnit {
override type A = BigDecimal
override def toString: String = s"$toBigDecimal BTC"
override def toString: String = s"$decimalString BTC"
def decimalString: String = "%.8f".format(toBigDecimal)
override def toBigDecimal: BigDecimal = underlying