www.digitalmars.com [Home] [Search] [Contents]

fltenv.h


feclearexcept

Header

fltenv.h

Prototype

int feclearexcept(int excepts);

Description

Clears the exceptions specified by excepts. The following exception flags expand to integer values that are a power of 2.

Flag/Meaning

FE_INEXACT
Inexact result
FE_DIVBYZERO
Divide by zero
FE_UNDERFLOW
Underflow
FE_OVERFLOW
Overflow
FE_INVALID
Invalid operand or operation
FE_ALL_EXCEPT
ORs all of the above exceptions

Return Value

Returns a non-zero value if all the exceptions specified by excepts are valid; otherwise, the return value is 0.

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

feraiseexcept


fegetenv

Header

fltenv.h

Prototype

void fegetenv(fenv_t * envp);

Description

Copies the current floating-point environment (rounding mode, precision mode, and exceptions) into the buffer pointed to by envp. Type fenv_t represents the state of the complete floating-point environment. Macro FE_DFL_ENV, which represents the default floating-point environment, expands to a value with type fenv_t. To use this function and the other functions defined in fltenv.h, your compiler must support the extensions to C as specified by the Numerical C Extensions Group (NCEG). The NCEG includes two predefined macros that determine if a compiler supports the extensions:

__FPCE__

When defined, indicates a compiler's compliance with the NCEG document. This macro is defined by the compiler as a constant value of 1.

__FPCE_IEEE__

When defined, indicates the compiler is compliant with the IEEE portion of the NCEG document. This macro is defined by the compiler as a constant value of 1.

Return Value

None

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

fesetenv


fegetexcept

Header

fltenv.h

Prototype

int fegetexcept(fexcept_t *flagp, int excepts);

Description

Stores (in the structure pointed to by flagp) an implementation-specific representation of the exception flag specified by excepts. Type fexcept_t represents an exception flag. The following exception flags expand to an integer value that is a power of 2.

Flag/Meaning
FE_INEXACT
Inexact result
FE_DIVBYZERO
Divide by zero
FE_UNDERFLOW
Underflow
FE_OVERFLOW
Overflow
FE_INVALID
Invalid operand or operation
FE_ALL_EXCEPT
ORs all of the above exceptions

Return Value

Returns a non-zero value if the exception specified by excepts is valid; otherwise, the return value is 0.

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

fegetenv for predefined macros in support of NCEG extensions.


fegetprec

Header

fltenv.h

Prototype

int fegetprec(void);

Description

Gets the current precision mode.

Return Value

The current precision mode.

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

fegetenv for predefined macros in support of NCEG extensions.


fegetround

Header

fltenv.h

Prototype

int fegetround(void);

Description

Gets the current rounding mode. The following rounding modes each expand to a unique, positive constant of type int:

Mode/Meaning
FE_TONEAREST
Round to nearest value.
UPWARD
Round toward positive infinity.
FE_DOWNWARD
Round toward negative infinity.
FE_TOWARDZERO
Round toward zero; drop fraction.
The value FLT_ROUNDS, declared in float. h, also evaluates to the current rounding mode.

Return Value

One of the rounding constants defined above.

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

fegetenv for predefined macros in support of NCEG extensions.


feprocentry

Header

fltenv.h

Prototype

void feprocentry(fenv_t * envp);

Description

Copies the current floating-point environment (rounding mode, precision mode, and exceptions) into the buffer pointed to by envp, and resets the floating-point environment to the start-up state (round to nearest, no loss in precision, and no exceptions set). Type fenv_t represents the state of the complete floating-point environment. Macro FE_DFL_ENV, which represents the default floating-point environment, expands to a value with type fenv_t.

Return Value

None

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

fegetenv for predefined marcros in support of NCEG extensions.


feprocexit

Header

fltenv.h

Prototype

void feprocexit(const fenv_t * envp);

Description

Saves the current exceptions internally, sets the floating-point environment to the values stored in the buffer pointed to by envp, and then raises the saved exceptions. Type fenv_t represents the state of the complete floating-point environment. Macro FE_DFL_ENV, which represents the default floating-point environment, expands to a value of type fenv_t.

Return Value

None

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

fegetenv for predefined macros in support of NCEG extensions.


feraiseexcept

Header

fltenv.h

Prototype

int feraiseexcept(int excepts);

Description

Raises the exceptions specified by excepts.

Return Value

Returns a non-zero value if all exceptions specified by excepts are valid; otherwise, the return value is 0. The following exception flags expand to integer values that are a power of 2.

Flag/Meaning
FE_INEXACT
Inexact result
FE_DIVBYZERO
Divide by zero
FE_UNDERFLOW
Underflow
FE_OVERFLOW
Overflow
FE_INVALID
lid operand or operation
FE_ALL_EXCEPT
ORs all of the above exceptions

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

feclearexcept
fegetenv for predefined macros in support of NCEG extensions.


fesetenv

Header

fltenv.h

Prototype

void fesetenv(const fenv_t *envp);

Description

Sets the current floating-point environment (rounding mode, precision mode, and exceptions) to the values stored in the buffer pointed to by envp. Type fenv_t represents the state of the complete floating-point environment. Macro FE_DFL_ENV, which represents the default floating-point environment, expands to a value with type fenv_t.

Return Value

None

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

fegetenv for predefined macros in support of NCEG extensions.


fesetexcept

Header

fltenv.h

Prototype

int fesetexcept(const fexcept_t *flagp, int excepts);

Description

Sets the implementation-specific exception flag (from the structure pointed to by flagp) of the exception flag specified by excepts. flagp should have been set by a previous call to fegetexcept; if not, the results are unpredictable. Type fexcept_t represents an exception flag. The following exception flags expand to integer values that are a power of 2.

Flag/Meaning
FE_INEXACT
Inexact result
FE_DIVBYZERO
Divide by zero
FE_UNDERFLOW
Underflow
FE_OVERFLOW
Overflow
FE_INVALID
Invalid operand or operation
FE_ALL_EXCEPT
ORs all of the above exceptions

Return Value

Returns non-zero if the exception specified by excepts is valid; Otherwise, the return value is 0.

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

fegetexcept
fegetenv for predefined macros in support of NCEG extensions.


fesetprec

Header

fltenv.h

Prototype

int fesetprec(int prec);

Description

Sets the precision mode to the value specified by prec. Precision mode has meaning only when inline coprocessor instructions are used; there is no affect without a coprocessor. The following precision modes each expands to a unique constant of type int. When the program begins, precision mode is FE_LDBLPREC.

Mode/Meaning
FE_FLTPREC
Use float (32-bit) precision
FE_DBLPREC
Use double (64-bit) precision
FE_LDBLPREC
Use long double (80-bit) precision

Return Value

If prec is not one of the values specified in section 17. 2. 7, fesetprec returns 0. Otherwise, it returns a non-zero value.

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

fegetprec
fegetenv for predefined macros in support of NCEG extensions.


fesetround

Header

fltenv.h

Prototype

int fesetround(int round);

Description

Sets the rounding mode. The previous rounding mode is forgotten. The following rounding modes each expands to a unique, positive constant of type int:

Mode/Meaning
FE_TONEAREST
Round to nearest value.
FE_UPWARD
Round toward positive infinity.
FE_DOWNWARD
Round toward negative infinity.
FE_TOWARDZERO
Round toward zero; drop fraction.

Return Value

Non-zero if successful; zero if invalid value given for round.

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

fegetround
fegetenv for predefined macros in support of NCEG extensions.


fetestexcept

Header

fltenv.h

Prototype

int fetestexcept(int excepts);

Description

This function determines if any of the exceptions specified by excepts have been raised. The following exception flags expand to integer values that are a power of 2.

Flag/Meaning
FE_INEXACT
Inexact result
FE_DIVBYZERO
Divide by zero
FE_UNDERFLOW
Underflow
FE_OVERFLOW
Overflow
FE_INVALID
Invalid operand or operation
FE_ALL_EXCEPT
ORs all of the above exceptions

Return Value

The bitwise OR of the exceptions corresponding to the currently-raised exceptions specified by excepts. If none of the specified exceptions is raised, the return value is zero.

Compatibility

DOS Windows 3.x Phar Lap DOSX Win32

See Also

fegetenv for predefined macros in support of NCEG extensions.