I came across a problem with _controlfp_s (Visual Studio 2008) or my understanding of this. I thought the first out parameter returned control flags before changes to other parameters were applied. It seems to return 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);
Did I miss something? It seems pretty silly to do this.
btw: I reported this to MS, who said that they couldn’t understand this, and suggested that I provide a video showing the problem. Yes, right.
Brad
source share