-
Small numbers
Hey guys,
Been out of programming for a while and just started working on an app to calculate relative velocities of minor planets. But i ran into a probelm, when i create a double or a float and assign 24/360 to it, it returns zero instead of .066666 like it should. I'm sure i'm just doing something stupid here.
Thanks a lot,
-
Could be a problem related to type casting. Try using 24.0 / 360.0.
When working with integers, no correct rounding occurs, you just lose the fractional portion completely. The compiler will interpret your code as dividing two integers, and so the result will be an integer - unless you do something like the above to change the division.
-
ah, thanks, should have remembered that :( , but i guess that's what time does to you ;)
-
Also it might be a good idea to postfix floating point values with f
ie.