_NutLibMSetLibraryType()

configure the math library floating point exception handling 

Function


SYNOPSIS

#include <math.h>

_LIB_VERSION_TYPE _NutLibMSetLibraryType (_LIB_VERSION_TYPE newtype);


DESCRIPTION

The math library can be configured to handle floating point exceptions in several different ways depending upon the desired level of standards conformance. There are currently 4 different personalities that are supported:

_IEEE_ 

The IEEE personality level is used to indicate conformance to IEEE 754. When a math exception is raised while the math library is in IEEE mode, the math library returns the value that is specified for the exception in question, but no other action is taken.

_POSIX_ 

In POSIX mode, the exception is handled by causing the floating point function to set the errno variable to indicate the type of exception. No other action is taken.

_XOPEN_ 

In the XOpen mode, the matherr function is called to notify the user application of the math exception. In the event that the matherr() function returns a 0 value, then an error message is displayed on stderr and the errno value is set, as specified.

_SVID_ 

In SVID mode, if matherr() is not supplied by the user, the default matherr() exception handling mechanisms, summarized in the table below, is invoked upon exception:

DOMAIN 

0.0 is usually returned, errno is set to EDOM, and a message is usually printed on standard error.

SING 

The largest finite single-precision number, HUGE of appropriate sign is returned, errno is set to EDOM, and a message is printed on standard error.

OVERFLOW 

The largest finite single-precision number, HUGE of appropriate sign is usually returned, errno is set to ERANGE.

UNDERFLOW 

0.0 is returned, and errno is set to ERANGE.

TLOSS 

0.0 is returned, errno is set to ERANGE, and a message is printed on standard error. In general, errno is not a reliable error indicator in that it may be unexpectedly set by a function in a handler for an asynchronous signal.

Further information regarding the behavior in the event an exception is raised is discussed in the individual reference pages for each math function.


PARAMETERS

newtype 

Is the new math library personality mode.


RETURN VALUES

The return value is the previous math library personality mode.


CONFORMANCE

None.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

At high levels of optimization, the Microsoft C compiler may replace calls with certain floating point functions with calls to the floating point processor. In this case, no exception information is reported, and the math library behaves as if in IEEE modeā€”the benefit in such situations is that the performance is improved. Applications that need to know about math exceptions (either through the errno variable, or through matherr() notifications) must be compiled without the optimizations and compiler pragmas that enable this inlining.

The set of floating point functions that have a true intrinsic form depends upon the compiler in use and the hardware on which the application is running. For the Microsoft C and C++ compilers, please see the compiler documentation for "#pragma intrinsic" for more information.

Some types of floating point exceptions, such as a floating point divide by zero, are not covered by the math library personality, and these exceptions do not cause errno to be set or the matherr() function to be called. Note however that the default behavior in the event of a floating point divide by zero can be configured with the _controlfp() function, and you can choose to have the condition ignored or reported. In the event that you have elected to receive notification and such an event occurs, the application receives a SIGFPE exception through the standard signal delivery mechanisms.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
math(), matherr()


PTC MKS Toolkit 10.5 Documentation Build 40.