...
On the same implementation, this program prints 0, implying that the integer value 1234567890 is representable in type double without change.
Exceptions
FLP36-C-EX1: Loss of precision can be acceptable when necessary for the proper execution of the program. It is recommended that the conversion be clearly commented as permitting loss of precision.
Risk Assessment
Conversion from integral types to floating-point types without sufficient precision can lead to loss of precision (loss of least significant bits).
Rule | Severity | Likelihood | Detectable | Remediation CostRepairable | Priority | Level |
|---|---|---|---|---|---|---|
FLP36-C | Low | Unlikely | Yes | NoMedium | P2 | L3 |
Automated Detection
Tool | Version | Checker | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Astrée |
| Supported: Astrée keeps track of all floating point rounding errors and loss of precision and reports code defects resulting from those. | ||||||||
| CodeSonar |
| LANG.TYPE.IAT | Inappropriate Assignment Type | |||||||
| Coverity |
| MISRA C 2004 Rule 10.x (needs investigation) | Needs investigation | |||||||
| Cppcheck Premium |
| premium-cert-flp36-c | Fully implemented||||||||
| Helix QAC |
| C1260, C1263, C1298, C1299, C1800, C1802, C1803, C1804, C4117, C4435, C4437, C4445 C++3011 | ||||||||
| Klocwork |
| PORTING.CAST.FLTPNT | ||||||||
| LDRA tool suite |
| 435 S | Fully implemented | |||||||
| Parasoft C/C++test |
| CERT_C-FLP36-a | Implicit conversions from integral to floating type which may result in a loss of information shall not be used | |||||||
| PC-lint Plus |
| 915, 922 | Partially supported | |||||||
| Polyspace Bug Finder |
| CERT-C: Rule FLP36-C | Checks for precision loss in integer to float conversion (rule fully covered) | |||||||
| PVS-Studio |
| V674 |
...