Math operation


#1

Why am I alway get 0 as a return when I build this code?

val test = 2*8/100

print(test)

output:0


#2

You are doing integer math. In particular, your division is integer division, which always rounds down.


#3

How can I calculate the percentage of a progress? Like this one:

val percentage = bytesReceived / fizeSize * 100

Thanks,


#4

I did.

val size = 10f
val percentage = bytesReceived / size * 100f


#5
val percentage = bytesReceived * 100 / fizeSize