INFO: Handling Floating-Point Errors in CLast reviewed: September 2, 1997Article ID: Q43391 |
The information in this article applies to:
SUMMARYWith Microsoft C, floating-point error-handling routines may be written using the signal() function; however, "return" should not be used to go back to the calling process. If "return" is used, the floating-point state is left undefined. Instead, use the setjmp() function to save the stack environment before each section of the calling process code that may potentially generate a floating-point error. In the error handler, use _fpreset() to reinitialize the floating-point package and longjmp() to return to the calling process. WARNING: Neither the setjmp nor longjmp function is compatible with the C++ language. The sample program on page 296 of the "Microsoft C/C++ Run-time Library Reference" that shipped with Microsoft C/C++ version 7.0 demonstrates the use of setjmp(), _fpreset(), and longjmp() to handle a floating-point error. The online help also provides samples for these functions. The function setjmp() saves the environment (bp, si, di, sp, and ds registers) and return address in a buffer. The buffer is used by longjmp() to restore the environment. Keywords : CRTIss kbfasttip Version : MS-DOS:6.00ax,7.0; OS/2:5.1,6.00a; WINDOWS:1.0,1.5; WINDOWS NT:1.0,2.0,4.0,4.1,5.0 Platform : MS-DOS NT OS/2 WINDOWS Issue type : kbinfo |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |