Rule A0-4-1 (required, infrastructure / toolchain, non-automated)

Floating-point implementation shall comply with IEEE 754 standard.

Rationale

Floating-point arithmetic has a range of problems associated with it. Some of these can be overcome by using an implementation that conforms to IEEE 754 (IEEE Standard for Floating-Point Arithmetic). Note that the rule implies that toolchain, hardware, C++ Standard Library and C++ built-in types (i.e. float, double) will provide full compliance to IEEE 754 standard in order to use floating-points in the project. Also, see: A0-4-2.

Example

//% $Id: A0-4-1.cpp 271389 2017-03-21 14:41:05Z piotr.tanski $
#include <limits>

static_assert(std::numeric_limits<float>::is_iec559,
"Type float does not comply with IEEE 754 single precision format");

static_assert( std::numeric_limits<float>::digits == 24,
"Type float does not comply with IEEE 754 single precision format");

static_assert( std::numeric_limits<double>::is_iec559,
"type double does not comply with IEEE 754 double precision format");

static_assert( std::numeric_limits<double>::digits == 53,
"Type double does not comply with IEEE 754 double precision format");

See also

MISRA C++ 2008 [7]: Rule 0-4-3 Floating-point implementations shall comply with a defined floating-point standard. JSF December 2005 [8]: AV Rule 146 Floating point implementations shall comply with a defined floating point standard.