How to convert a BigDecimal to a double in Kotlin

1 Answer

0 votes
import java.math.BigDecimal

fun main() {
    val dec = BigDecimal("12.3456")
    val d = dec.toDouble()

    println("BigDecimal value: $dec")
    println("Double value: $d")
}



/*
run:

BigDecimal value: 12.3456
Double value: 12.3456

*/

 



answered Apr 12 by avibootz
...