...
This noncompliant code example compares the string representations of two floating-point values.:
Code Block | ||
---|---|---|
| ||
int i = 1; String s = Double.valueOf(i / 1000.0).toString(); if (s.equals("0.001")) { // ... } |
The comparison unexpectedly fails because s
contains the string "0.0010001"
.
Noncompliant Code Example (Regex)
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
NUM11-J | lowLow | likelyLikely | mediumMedium | P6 | L2 |
Related Vulnerabilities
...
[API 2006] | |
[JLS 2005] | |
[Seacord 2015] | NUM11-J. Do not compare or inspect the string representation of floating-point values LiveLesson |
...