-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
> **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 | ||
|
||
```cpp | ||
//% $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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,5 @@ | ||
> **Rule M0-4-2 (required, implementation, non-automated)** | ||
> | ||
> Use of floating-point arithmetic shall be documented. | ||
> See MISRA C++ 2008 [7] | ||
> 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 | ||
|
||
```cpp | ||
//% $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. | ||
See MISRA C++ 2008 [7] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters