---
title: "CWE-1339: Insufficient Precision or Accuracy of a Real Number"
url: https://radicalnotion.ai/cwe/cwe-1339
type: cwe
description: "The product processes a real number with an implementation in which the number's representation does not preserve required accuracy and precision in its fractional part, causing an incorrect result."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-1339: Insufficient Precision or Accuracy of a Real Number

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 2
- **Of those, in CISA KEV:** 0
- **New in 2026:** 1
- **CWE catalog version:** 4.21

## Description

The product processes a real number with an implementation in which the number's representation does not preserve required accuracy and precision in its fractional part, causing an incorrect result.

When a security decision or calculation requires highly precise, accurate numbers such as financial calculations or prices, then small variations in the number could be exploited by an attacker.

If the fraction can be represented in a fixed number of digits (binary or decimal), there might not be enough digits assigned to represent the number. In other cases, the number cannot be represented in a fixed number of digits due to repeating in decimal or binary notation (e.g. 0.333333...) or due to a transcendental number such as Π or √2. Rounding of numbers can lead to situations where the computer results do not adequately match the result of sufficiently accurate math.

## Background

There are multiple ways to store the fractional part of a real number in a computer. In all of these cases, there is a limit to the accuracy of recording a fraction. There are three major ways to store real numbers. 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.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | This weakness is introduced when the developer picks a method to represent a real number. The weakness may only be visible with very specific numeric inputs. |

## Applicable platforms

**Languages:** Python (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| 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 | The results of the math are not as expected. This could cause issues where a value would not be properly calculated and provide an incorrect answer. |
| Confidentiality, Availability, Access Control | Read Application Data, Modify Application Data | This weakness can sometimes trigger buffer overflows which can be used to execute arbitrary code. This is usually outside the scope of a product's implicit security policy. |

## Potential mitigations

### Implementation, Patching and Maintenance

The developer or maintainer can move to a more accurate representation of real numbers. In extreme cases, the programmer can move to representations such as ratios of BigInts which can represent real numbers to extremely fine precision. The programmer can also use the concept of an Unum real. The memory and CPU tradeoffs of this change must be examined. Since floating point reals are used in many products and many locations, they are implemented in hardware and most format changes will cause the calculations to be moved into software resulting in slower products.

## Detection methods

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

## Demonstrative examples

### Example 1

Muller's Recurrence is a series that is supposed to converge to the number 5. When running this series with the following code, different implementations of real numbers fail at specific iterations:

Bad code:

```rust
fn rec_float(y: f64, z: f64) -> f64
{
    108.0 - ((815.0 - 1500.0 / z) / y);
}

fn float_calc(turns: usize) -> f64
{
    let mut x: Vec<f64> = vec![4.0, 4.25];
    (2..turns + 1).for_each(|number|
    {
        x.push(rec_float(x[number - 1], x[number - 2]));
    });

    x[turns]
}
```

Good code:

```rust
Use num_rational::BigRational;

fn rec_big(y: BigRational, z: BigRational) -> BigRational
{
    BigRational::from_integer(BigInt::from(108))
        - ((BigRational::from_integer(BigInt::from(815))
        - BigRational::from_integer(BigInt::from(1500)) / z)
        / y)
}

fn big_calc(turns: usize) -> BigRational
{
    let mut x: Vec<BigRational> = vec![BigRational::from_float(4.0).unwrap(), BigRational::from_float(4.25).unwrap(),];

    (2..turns + 1).for_each(|number|
    {
        x.push(rec_big(x[number - 1].clone(), x[number - 2].clone()));
    });
    x[turns].clone()
}
```

The chart below shows values for different data structures in the rust language when Muller's recurrence is executed to 80 iterations. The data structure f64 is a 64 bit float. The data structures I\<number\>F\<number\> are fixed representations 128 bits in length that use the first number as the size of the integer and the second size as the size of the fraction (e.g. I16F112 uses 16 bits for the integer and 112 bits for the fraction). The data structure of Ratio comes in three different implementations: i32 uses a ratio of 32 bit signed integers, i64 uses a ratio of 64 bit signed integers and BigInt uses a ratio of signed integer with up to 2^32 digits of base 256. Notice how even with 112 bits of fractions or ratios of 64bit unsigned integers, this math still does not converge to an expected value of 5.

### Example 2

On February 25, 1991, during the eve of the Iraqi invasion of Saudi Arabia, a Scud missile fired from Iraqi positions hit a US Army barracks in Dhahran, Saudi Arabia. It miscalculated time and killed 28 people \[REF-1190\].

### Example 3

Sleipner A, an offshore drilling platform in the North Sea, was incorrectly constructed with an underestimate of 50% of strength in a critical cluster of buoyancy cells needed for construction. This led to a leak in buoyancy cells during lowering, causing a seismic event of 3.0 on the Richter Scale and about $700M loss \[REF-1281\].

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2018-16069 | Chain: series of floating-point precision errors (CWE-1339) in a web browser rendering engine causes out-of-bounds read (CWE-125), giving access to cross-origin data |
| CVE-2017-7619 | Chain: rounding error in floating-point calculations (CWE-1339) in image processor leads to infinite loop (CWE-835) |
| CVE-2021-29529 | Chain: machine-learning product can have a heap-based buffer overflow (CWE-122) when some integer-oriented bounds are calculated by using ceiling() and floor() on floating point values (CWE-1339) |
| CVE-2008-2108 | Chain: insufficient precision (CWE-1339) in random-number generator causes some zero bits to be reliably generated, reducing the amount of entropy (CWE-331). |
| CVE-2006-6499 | Chain: web browser crashes due to infinite loop - "bad looping logic \[that relies on\] floating point math \[CWE-1339\] to exit the loop \[CWE-835\]" |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-88360 | libvips: libvips: Denial of Service via Malformed PFM Image Processing | high | 7.5 | - | No | 2026-09-24 |
| CVE-2025-38508 | x86/sev: Use TSC\_FACTOR for Secure TSC frequency calculation | high | 7.3 | - | No | 2025-08-16 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-682](https://radicalnotion.ai/cwe/cwe-682) | Incorrect Calculation |
| Peer | [CWE-190](https://radicalnotion.ai/cwe/cwe-190) | Integer Overflow or Wraparound |
| Can precede | [CWE-119](https://radicalnotion.ai/cwe/cwe-119) | Improper Restriction of Operations within the Bounds of a Memory Buffer |
| Can precede | [CWE-834](https://radicalnotion.ai/cwe/cwe-834) | Excessive Iteration |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| OpenSSF Secure Coding Guide for Python | Control Numeric Precision | pyscg-0001 | - |

## Frequently asked questions

### What is CWE-1339?

The product processes a real number with an implementation in which the number's representation does not preserve required accuracy and precision in its fractional part, causing an incorrect result.

### What CVEs are caused by CWE-1339?

2 recorded CVEs are attributed to CWE-1339, including CVE-2026-88360 and CVE-2025-38508.

### How do you prevent CWE-1339?

The developer or maintainer can move to a more accurate representation of real numbers. In extreme cases, the programmer can move to representations such as ratios of BigInts which can represent real numbers to extremely fine precision. The programmer can also use the concept of an Unum real. The memory and CPU tradeoffs of this change must be examined. Since floating point reals are used in many products and many locations, they are implemented in hardware and most format changes will cause the calculations to be moved into software resulting in slower products.

### How is CWE-1339 detected?

Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

### What are the consequences of CWE-1339?

Exploiting CWE-1339 can lead to: DoS: Crash, Exit, or Restart, Execute Unauthorized Code or Commands, Read Application Data, Modify Application Data.

### Is CWE-1339 actively exploited?

2 recorded CVEs are caused by CWE-1339; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/1339.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-1339). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
