I want to set in text view full value of Double without scientific notation (Exponential), what is best approach?
I tried convert Double value using method toString() on it, but I still have scientific value.
tvDepth.text=depth.toString()
I entered value 123456789.123456789 and expect same value in textView, but instead I have: 1.23456789123456789E8.
I don't know how many decimal places I need, so I couldn't format it before set it in text view. I read that in Java is available static method
Double.toString(Double d)
but it's not available in Kotlin. Is there any good approach to show this value correctly?
You can use .toBigDecimal().toPlainString()
on your Double
. For example:
println(PI.toBigDecimal().toPlainString())
prints out:
3.141592653589793
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With