We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
always use float (Read 1366 times)
always use float
May 15th, 2005, 3:52am
 
It'd be a useful preprocessor feature if you could specify that you always want constants to be interpreted as floats. Just had a bit of a headache before I realized that 3 / 4 is 0 in integer math...
Re: always use float
Reply #1 - May 15th, 2005, 4:53pm
 
hm, can't really be done so well, since it'll screw up things like array indexing. the whole int vs float thing is just one of those things to get used to with programming.

it actually comes in useful in a lot of places, for instance, walking through an array and getting coordinates:

Code:
for (int i = 0; i < pixels.length; i++) {
if (pixels[i] == 0xff808000) {
int y = i / width;
int x = i % width;
println("found color at " + x + ", " + y);
}
}
Page Index Toggle Pages: 1