% (mod) for floats

Need some code to perform a mod style algorithm on floats or doubles.

So... 123.2 % 3 = 0.2

Any ideas?
1
2
// goal:   result = orig % mod
result = orig - ( (int)(orig / mod) * mod );
Funky. Nice one.
oh yeah.. duh. I always forget fmod exists because I confuse it for modf.
Topic archived. No new replies allowed.