tags:

views:

294

answers:

2

For given floating point numbers x and a, I would like to compute r (and n) such that x = a*n + r . In C/C++ this function is called fmod. However I do not see a convenient function in .NET. Math.DivRem is only for integers ...

+5  A: 

I think you can just use % for floats as well. r = x % a

http://msdn.microsoft.com/en-us/library/0w4e0fzs.aspx

All numeric types have predefined modulus operators.

Andreas Brinck
+1  A: 

I think you are looking for System.Math.IeeeRemainder

Kindness,

Dan

Daniel Elliott