Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>_control87() get and set 8087/80287 status word</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_control87()             Get and Set 8087/80287 Status Word

 #include   <float.h>

 unsigned int   control87(new, mask); Floating-point control word
 unsigned int   new;                  New control-word bit values
 unsigned int   mask;                 Mask for new control-word bits to set

    _control87() gets the floating-point control word and then sets it.
    If 'mask' is 0, then the control word is not set.  If 'mask' is non-
    zero, then the control word is set by the following expression:

             control_word = ((control_word & ~mask) | (new & mask));

    The floating-point control word determines the precision, rounding,
    and infinity modes in the floating-point math package as well as the
    floating-point exceptions that may occur.

    The bits in the control word (defined in <float.h>) are assigned as
    follows:

                 EM_INVALID           Invalid interrupt enabled
                 EM_DENORMAL          Denormal interrupt enabled
                 EM_ZERODIVIDE        Divide by zero interrupt enabled
                 EM_OVERFLOW          Overflow interrupt enabled
                 EM_UNDERFLOW         Underflow interrupt enabled
                 EM_INEXACT           Loss of precision interrupt enabled
                 IC_AFFINE            Affine infinity control
                 IC_PROJECTIVE        Projective control
                 RC_CHOP              Chop rounding control
                 RC_UP                Up rounding control
                 RC_DOWN              Down rounding control
                 RC_NEAR              Near rounding control
                 PC_24                24 bit precision control
                 PC_53                53 bit precision control
                 PC_64                64 bit precision control

    The following control word masks are defined in <float.h>:

                 MCW_EM               Interrupt exception mask
                 MCW_IC               Infinity control mask
                 MCW_RC               Rounding control mask
                 MCW_PC               Precision control mask

    Returns:     Floating-point control word.

  -------------------------------- Example ---------------------------------

         #include <stdio.h>
         #include <float.h>

         double tenth = .1;

         main()
         {
             /* get control word */
             printf("control = %.4x\n",_control87(0,0));
             printf("a*a = .01 = %.15e\n",a*a);

             /* set precision to 24 bits */
             _control87(PC_24,MCW_PC);
             printf("a*a = .01 (rounded to 24 bits) = %.15e\n",a*a);

             /*restore to initial default */
             _control87(CW_DEFAULT,0xffff);
             printf("a*a = .01 = %.15e\n",a*a);
          }

See Also: _clear87() _status87()

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