mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 14:33:06 +01:00
Remove scientific notation from Bitcoins.toString() (#3811)
This commit is contained in:
parent
86bd52d7f2
commit
0b3654f020
2 changed files with 9 additions and 2 deletions
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue