_control87()

NAME

_control87() - get and set floating point control word

SYNOPSIS

#include <float.h>

unsigned int _control87( unsigned int newcw, unsigned int mask);

DESCRIPTION

The _control87() function updates the control word of the 8087/80287/80387/80486. If mask is zero, then the control word is not updated. If mask is non-zero, then the control word is updated with bits from newcw corresponding to each bit that is on in mask.

RETURN VALUES

The _control87() function returns the new control word. The description of bits defined for the control word is found in the float.h header file.

EXAMPLE

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

char *status[2] = { "disabled", "enabled" };

void main()
  {
	unsigned int fp_cw = 0;
	unsigned int fp_mask = 0;
	unsigned int bits;

	fp_cw = _control87( fp_cw,
						fp_mask );

	printf( "Interrupt Exception Masks\n" );
	bits = fp_cw & MCW_EM;
	printf( "  Invalid Operation exception %s\n",
			status[ (bits & EM_INVALID) == 0 ] );
	printf( "  Denormalized exception %s\n",
			status[ (bits & EM_DENORMAL) == 0 ] );
	printf( "  Divide-By-Zero exception %s\n",
			status[ (bits & EM_ZERODIVIDE) == 0 ] );
	printf( "  Overflow exception %s\n",
			status[ (bits & EM_OVERFLOW) == 0 ] );
	printf( "  Underflow exception %s\n",
			status[ (bits & EM_UNDERFLOW) == 0 ] );
	printf( "  Precision exception %s\n",
			status[ (bits & EM_PRECISION) == 0 ] );

	printf( "Infinity Control = " );
	bits = fp_cw & MCW_IC;
	if( bits == IC_AFFINE )	 printf( "affine\n" );
	if( bits == IC_PROJECTIVE ) printf( "projective\n" );

	printf( "Rounding Control = " );
	bits = fp_cw & MCW_RC;
	if( bits == RC_NEAR )	 printf( "near\n" );
	if( bits == RC_DOWN )	 printf( "down\n" );
	if( bits == RC_UP )		 printf( "up\n" );
	if( bits == RC_CHOP )	 printf( "chop\n" );

	printf( "Precision Control = " );
	bits = fp_cw & MCW_PC;
	if( bits == PC_24 )		 printf( "24 bits\n" );
	if( bits == PC_53 )		 printf( "53 bits\n" );
	if( bits == PC_64 )		 printf( "64 bits\n" );
  }