Intel® C++ Compiler 16.0 User and Reference Guide

Floating-point Formats

This IEEE Standard 754™-2008 specifies formats and methods for floating-point representation in computer systems, and recommends formats for data interchange. Exception conditions are defined, and standard handling of these conditions is specified.

The binary counterpart floating-point exception functions are described in ISO C99.

The decimal floating-point exception functions are defined in the fenv.h header file.

The compiler supports decimal floating point types in C and C++. The decimal floating point formats are defined in IEEE Standard 754™-2008. In C, the following decimal floating types are supported: _Decimal32, _Decimal64, and _Decimal128. In C++ for Windows* and Linux*, these decimal classes are supported: decimal32, decimal64, and decimal128 (decimal floating-point in C++ for OS X* is not supported). To use this feature in C++ on Linux*, gcc 4.5 or later is required.

To ensure correct decimal floating-point behavior, the user must define __STDC_WANT_DEC_FP__ before any standard headers are included. This is required for the declaration of decimal macros and library functions in order to ensure correct decimal floating-point results at run-time.

Example: Linux*

#include <iostream>
#define __STDC_WANT_DEC_FP__
#include <decimal/decimal>
typedef std::decimal::decimal32 _Decimal32;
typedef std::decimal::decimal64 _Decimal64;
typedef std::decimal::decimal128 _Decimal128;
#include <dfp754.h>

using namespace std;
using namespace std::decimal;

int main() {
    std::decimal::decimal32 d = 4.7df;
    std::cout << decimal_to_long_double(d) << std::endl; 
    return 0; 
}

Example: Windows*

#include <iostream>
#define __STDC_WANT_DEC_FP__
#include <decimal>
#include <dfp754.h>

using namespace std;
using namespace std::decimal;

int main() {
    std::decimal::decimal32 d = 4.7df;
    std::cout << decimal_to_long_double(d) << std::endl; 
    return 0; 
}

Functions to check decimal FP status

To detect exceptions occurring during decimal floating-point arithmetic, use the following floating-point exception functions:

Function

Brief Description

fe_dec_feclearexcept()

Clears the supported floating-point exceptions.

fe_dec_fegetexceptflag

Stores an implementation-defined representation of the states of the floating-point status flags.

fe_dec_feraiseexcept

Raises the supported floating-point exceptions.

fe_dec_fesetexceptflag

Sets the floating-point status flags.

fe_dec_fetestexcept()

Determines which of a specified subset of the floating point exception flags are currently set.