Why am I alway get 0 as a return when I build this code?
val test = 2*8/100
print(test)
output:0
Why am I alway get 0 as a return when I build this code?
val test = 2*8/100
print(test)
output:0
You are doing integer math. In particular, your division is integer division, which always rounds down.
How can I calculate the percentage of a progress? Like this one:
val percentage = bytesReceived / fizeSize * 100
Thanks,
I did.
val size = 10f
val percentage = bytesReceived / size * 100f
val percentage = bytesReceived * 100 / fizeSize