_fpreset
Reinitializes floating-point math package.
Defined in header <float.h>
Syntax
#include <float.h>
void _fpreset(void);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
_fpreset reinitializes the floating-point math package. This function is usually used in conjunction with system or the exec... or spawn... functions.
b^
Under DOS, if an 80x87 coprocessor is used in a program, a child process (executed by system or by an exec... or spawn... function) might alter the parent process's floating-point state.
If you use an 80x87, take the following precautions:
EI Do not call system or an exec... or spawn... function while a floating-point expression is being evaluated. D Call _fpreset to reset the floating-point state after using system, exec..., or spawn... if there is any chance that the child process performed a floating-point operation with the 80x87.
Return value
None.
See also
_clear87_control87execspawn_status87system
Example
include <stdio.h>
#include <float.h>
#include <setjinp.h>
#include <signal.h>
#include <process.h>
#include <conio.h>
#ifdef cplusplus
typedef void (*fptr)(int);
telse
typedef void (*fptr)();
tendif
]inp_buf reenter;
/* define a handler for trapping floating
point errors */
void float_trap(int sig)
{
printf( "Trapping floating point error,");
printf ("signal is %d\n",sig);
printf ("Press a key to continue\n");
getchO ;
/* Reset the 8087 chip or emulator to clear any extraneous garbage. */
_fpreset ();
/* return to the problem spot */
longjmp (reenter, -1);
}
int main (void)
float one = 3.14, two = 0.0;
/* Install signal handler for floating point exception. */
signal (SIGFPE, (fptr)float_trap);
printf ("Generating a math error,");
printf ("press a key\n");
getchO ;
if (setjmp(reenter) == 0)
one /= two;
printf ("Returned from signal trap\n");
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `Jpreset` read as `_fpreset`
Stable link: /3.1/float.h/_fpreset/
· short form /3.1/_fpreset/