_fpreset() Reinitialize Floating-Point Math Package
#include <float.h>
void _fpreset(void);
_fpreset() reinitializes the floating-point math package.
Returns: There is no return value.
Notes: On versions of MS-DOS prior to 4.0, a child process
executed by system(), exec(), or spawn() that used the
8087/80287 coprocessor could affect the floating-point
state of the parent process if a numeric coprocessor was
used. The following precautions are recommended when
using an 8087 or 80287:
exec...(), spawn...(), or system() should not be called
during the evaluation of a floating-point expression, and
_fpreset() should be called after the child process
finishes if there is a possibility that any 8087 or 80287
floating-point operations were performed.
-------------------------------- Example ---------------------------------
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include <float.h>
int fphandler();
jum_buf mark;
double a = 1.0, b = 0.0, c;
main()
{
if (signal(SIGFPE,fphandler) == (int(*) ())-1)
abort();
if (setjmp(mark) == 0) {
c = a/b;
printf("Should never get here\n");
}
printf("Recovered from floating-point error\n");
}
int fphandler(sig,num)
int sig,num;
{
printf("signal = %d subcode = %d\n",sig,num);
_fpreset();
longjmp(mark,-1);
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster