Sign in to follow this  

Win32 Exceptions

This topic is 2661 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a small problem regarding Win32 exceptions like overflow, division by zero, etc...

I have to work with some legacy code that performs all kind of ugly operations and casts doubles to integers without validating the parameters first. Although I've disabled floating point exceptions (through the project's code generation property sheet), an "invalid floating point operation" is still thrown at some point, when casting a double to an unsigned short (the double is way too high, but I'm required to ignore it). What could be responsible for throwing that exception in the first place and what can I do to simply ignore it?

Share this post


Link to post
Share on other sites
Did you try _controlfp_s?

Something like this should do:


#include <float.h>

unsigned int currentControl;
// Disable floating point exceptions
_controlfp_s(¤tControl, 0, _MCW_EM);

// Restore previous state
_controlfp_s(¤tControl, currentControl, _MCW_EM);

Share this post


Link to post
Share on other sites

This topic is 2661 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this