Maybe some of you more knowledgeable people can help me with this one. I
have a bunch of math functions I am porting to VB.NET/C# from 'C' code. I
have used the fmod() 'C' function a great deal. I do not want to use the
VB Mod operator to port the code because I also want to be able (if need
be) create a C# equivalent and use the function method which is also recognizable
by Fortran programmers. I thought the Math.IEEERemainder function would be
a replacement for the 'C' fmod() function but if it is I have a major problem
- sometimes Math.IEEERemainder returns the same value as fmod() and sometimes
it does not???

For example, in the case below a value of 40.00000 is returned from the
'C' function as I expected:
xval = fmod(400.0, 360.0); //The C function returns 40.000000

The equivalent VB.NET function also returns the expected result with this
value of 40.000000
xval = Math.IEEERemainder(400, 360) 'This also returns 40.000000

In the next case however I use a value of 560.0 and the 'C' function returns
the desired correct result of 200.000000:
xval = fmod(560.0, 360.0); //The C function returns 200.000000

The equivalent VB.NET code using the value of 560.0 returns a value of -160.000000
which is NOT the result I expected!
xval = Math.IEEERemainder(560.0, 360.0) 'This returns -160.000000 but I thought
it would return 200.000000 as the 'C' function does.

Is Math.IEEERemainder(x, y) a replacement for the 'C' fmod() function or
NOT? Is this a bug? Can any of you help me with this problem?

Thanks in advance,