C# Math vs. XNA MathHelper


Ever since I needed to work with PI (3.1415…) in C# I have used Math.PI to get the value. Usually I would just use values like Math.PI/2.0 or 2.0*Math.PI, but now I have just noticed that XNA provides a MathHelper class. The nice thing about this is I can call MathHelper.PiOver2 and MathHelper.TwoPi, thus making an extremely trivial step even more trivial. 😉

I assumed these two classes were interchangable, but I noticed that Math.PI/2.0 != MathHelper.PiOver2. I tried to research why this would be, but I found nothing. So, I thought I would try my luck here. With regards to using PI, are there any differences between the Math class and the MathHelper class? Is one preferred over the other? Or should I just leave well enough alone and just make sure to consistently use one or the other throughout my program?

Best Solution

How not equal are they? If they are sufficiently close, this might just be the traditional problem that testing equality with floating points is near impossible.

Also, are they of the same type? My opinion was most gaming calculations were done with floats, where as Math.PI would be a double.

EDIT: MathHelper does indeed use floats

Related Question