Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>_fpreset() reinitialize floating-point math package</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_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);
          }

See Also: exec...() spawn...() system()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson