How to convert a BigDecimal to a double in Scala

1 Answer

0 votes
object BigDecimalToDoubleDemo {
  def main(args: Array[String]): Unit = {
    val dec = BigDecimal("12.3456")
    val d: Double = dec.toDouble

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


/*
run:

BigDecimal value: 12.3456
Double value: 12.3456

*/

 



answered Apr 12 by avibootz

Related questions

1 answer 93 views
1 answer 242 views
242 views asked May 31, 2021 by avibootz
1 answer 71 views
1 answer 69 views
1 answer 195 views
...