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

Related questions

1 answer 88 views
88 views asked Oct 31, 2024 by avibootz
1 answer 120 views
120 views asked Oct 12, 2024 by avibootz
1 answer 179 views
2 answers 129 views
...