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 85 views
1 answer 219 views
219 views asked May 31, 2021 by avibootz
1 answer 63 views
1 answer 59 views
1 answer 189 views
...