Article ID: 94998 - Last Review: November 21, 2006 - Revision: 4.1 INFO: Trapping Floating-Point Exceptions in a Win32-based App
This article was previously published under Q94998 SUMMARY
The _controlfp() function is the portable equivalent to the _control87()
function.
To trap floating-point (FP) exceptions via try-except (such as EXCEPTION_FLT_OVERFLOW), insert the following before doing FP operations: Note that any handler for FP errors should have _clearfp() as its first FP instruction. MORE INFORMATION
By default, Windows NT has all the FP exceptions turned off, and thus
computations result in NAN or INFINITY rather than an exception. Note,
however, that if an exception occurs and an explicit handler does not exist
for it, the default exception handler will terminate the process.
If you want to determine which mask bits are set and which are not during exception handling, you need to use _clearfp() to clear the floating-point exception. This routine returns the existing FP status word, giving the necessary information about the exception. After this, it is safe to query the chip for the state of its control word with _controlfp(). However, as long as an unmasked FP exception is active, most FP instructions will fault, including the fstcw in _controlfp(). APPLIES TO
| Other Resources Other Support Sites
CommunityArticle Translations |






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email
Back to the top