How to specify which round method to call for float and double in Scala

1 Answer

0 votes
// The methods are distinguished by argument types. 

println(Math.round(15.4)) 
println(Math.round(15.4f))
println(Math.round(15.4.floatValue))

println(Math.round(15.5)) 
println(Math.round(15.5f))
println(Math.round(15.5.floatValue))



/*
run:
    
15
15
15
16
16
16
  
*/

 



answered May 14, 2025 by avibootz

Related questions

...