How to convert string to float in Scala

1 Answer

0 votes
object Main {
  def main(args: Array[String]): Unit = {
    val str: String = "8479.5361"

    val f: Float = str.toFloat
    
    println(f)  
  }
}
 
 
    
/*
run:
    
8479.536
    
*/

 



answered Oct 31, 2024 by avibootz
edited Oct 31, 2024 by avibootz
...