exquisitus wrote:
I'm trying to decide which of these two to use to calculate the
remainder between two floating point numbers. My gut instinct says to go
for the % operator - but I'm not sure if I am right. Which is the
correct one (i.e. more effecient) and why?
The % operator only works for integer arguments; moreover, as
% is defined in terms of / (i.e. a -(a/b)*b == a%b, if b!=0),
there is no sensible value, as we do not necessarily "lose"
something (which also could be recovered by a % operation)
by a "floating point" division.
So, fmod() is your way to go.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.