Hi All,
I've stumbled across either a problem with _controlfp_s (Visual Studio 2008), or my understanding of it. I thought the first out parameter returned the control flags before changes of the other parameters are applied. Seems it returns the flags after the change.
So, I thought the correct way to use it was like this:
// Chop rounding
unsigned int old;
_controlfp_s(&old, _RC_CHOP, _MCW_RC);
// Do chopped math
// Restore
unsigned int unused;
_controlfp_s(&unused, old, _MCW_RC);
Unfortunately I need to do this:
// Save
unsigned int old1;
_controlfp_s(&old1, 0, 0);
// Chop rounding
unsigned int old2;
_controlfp_s(&old2, _RC_CHOP, _MCW_RC);
// Do chopped math
// Restore
unsigned int unused;
_controlfp_s(&unused, old1, _MCW_RC);
Have I missed something? Seems pretty stupid to have to do this.
btw: I've reported this to MS who said they couldn't understand it and suggested I provide a video showing the problem. Yeah right.
Brad