We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi
From some reason println(float(291664/1239570))
println(float(291664/1239570))
results in 0.0
0.0
a) Why is that? b) is there a way to solve it?
Try println( (float) 291664/1239570);
println( (float) 291664/1239570);
Or if you prefer Processing syntax println(float(291664)/1239570);
println(float(291664)/1239570);
Note that by putting the division inside the brackets you're converting to a floating point number after you've done the integer division.
https://Forum.Processing.org/two/discussions/tagged/division
https://forum.processing.org/two/discussion/24027/integer-division-why-does-2-5-0
Answers
Try
println( (float) 291664/1239570);
Or if you prefer Processing syntax
println(float(291664)/1239570);
Note that by putting the division inside the brackets you're converting to a floating point number after you've done the integer division.
https://Forum.Processing.org/two/discussions/tagged/division
https://forum.processing.org/two/discussion/24027/integer-division-why-does-2-5-0