NO

Author Topic: The case of fmod?  (Read 3477 times)

andre104

  • Guest
The case of fmod?
« on: November 27, 2012, 05:27:32 AM »
I know that in C we can calculate the modulus operation of floating points using fmod.
I'd like to ask what are the cases in which such operation is needed?

What I mean is floating point number is an un-exact representation. Dividing a float with a float yields another float.
So, why we do this?  :-\


akko

  • Guest
Re: The case of fmod?
« Reply #1 on: November 28, 2012, 12:39:31 PM »
This can only be answered within the context of your specific problem domain.

If you need more generic information, try
http://floating-point-gui.de/
and
http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

CommonTater

  • Guest
Re: The case of fmod?
« Reply #2 on: November 28, 2012, 04:07:21 PM »
I know that in C we can calculate the modulus operation of floating points using fmod.
I'd like to ask what are the cases in which such operation is needed?

What I mean is floating point number is an un-exact representation. Dividing a float with a float yields another float.
So, why we do this?  :-\

I believe it's called "mathematics"....
 
Personally I avoid floating point math whenever possible. *Especially* when you're playing with money.  In Canada we use dollars, which are 100 pennies... so everything is converted to pennies and manipulated with integer math. 
 
There are times to use these "higher functions", and that will depend entirely on what you're doing... Calculating orbital trajectories would be one example.
 
 
« Last Edit: November 28, 2012, 04:10:17 PM by CommonTater »