293
CanPrecede 834 Excessive Iteration 1754
Relevant to the view "Software Development" (CWE-699)
Nature Type ID Name Page
MemberOf 189 Numeric Errors 2312
Applicable Platforms
Language : Not Language-Specific (Prevalence = Undetermined)
Operating_System : Not OS-Specific (Prevalence = Undetermined)
Architecture : Not Architecture-Specific (Prevalence = Undetermined)
Technology : Not Technology-Specific (Prevalence = Undetermined)
Background Details
There are three major ways to store real numbers in computers. Each method is described along
with the limitations of how they store their numbers.
• Fixed: Some implementations use a fixed number of binary bits to represent both the integer
and the fraction. In the demonstrative example about Muller's Recurrence, the fraction 108.0 -
((815.0 - 1500.0 / z) / y) cannot be represented in 8 binary digits. The numeric accuracy within
languages such as PL/1, COBOL and Ada is expressed in decimal digits rather than binary
digits. In SQL and most databases, the length of the integer and the fraction are specified by
the programmer in decimal. In the language C, fixed reals are implemented according to ISO/
IEC TR18037
• Floating: The number is stored in a version of scientific notation with a fixed length for the
base and the significand. This allows flexibility for more accuracy when the integer portion
is smaller. When dealing with large integers, the fractional accuracy is less. Languages
such as PL/1, COBOL and Ada set the accuracy by decimal digit representation rather than
using binary digits. Python also implements decimal floating-point numbers using the IEEE
754-2008 encoding method.
• Ratio: The number is stored as the ratio of two integers. These integers also have their limits.
These integers can be stored in a fixed number of bits or in a vector of digits. While the vector
of digits method provides for very large integers, they cannot truly represent a repeating or
transcendental number as those numbers do not ever have a fixed length.
Common Consequences
Scope Impact Likelihood
Availability DoS: Crash, Exit, or Restart
This weakness will generally lead to undefined results and
therefore crashes. In some implementations the program
will halt if the weakness causes an overflow during a
calculation.
Integrity Execute Unauthorized Code or Commands
CWE Version 4.14
CWE-1339: Insufficient Precision or Accuracy of a Real Number
CWE-1339: Insufficient Precision or Accuracy of a Real Number