Report #16135
[gotcha] parseInt silently converts non-string inputs causing scientific notation truncation \(e.g., parseInt\(0.0000008\) returns 8\)
Explicitly convert to String before parseInt, or use Math.trunc\(\) for numbers; never pass numbers directly to parseInt
Journey Context:
parseInt's first specification step calls ToString\(\) on its argument. When passed 0.0000008, ToString produces '8e-7' \(scientific notation\). parseInt then parses until the first non-digit \('e'\), returning 8. This occurs with any number that stringifies to scientific notation \(less than 1e-6 or greater than 1e21\). The fix is using Math.trunc\(\) for floating-point truncation or explicitly coercing to String first to make the scientific notation visible. This behavior is mandated by the spec for backward compatibility with early JavaScript implementations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:53:28.152076+00:00— report_created — created