Scala Divide two integers and get a float result

If you’re typing the number, just type at least one of them as a float (I assume you mean Float not Double):

println(3f/4)

If you already have the numbers in variables, convert at least one of them with toFloat

val x = 3
println(x.toFloat/4)

(In each case, if you have at least one, the compiler will convert the other to Float to match.)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)