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 203 views
1 answer 352 views
352 views asked May 31, 2021 by avibootz
1 answer 175 views
175 views asked Oct 31, 2024 by avibootz
1 answer 163 views
163 views asked Oct 31, 2024 by avibootz
1 answer 302 views
...