Report #57064
[gotcha] parseInt silently truncates numbers in scientific notation \(e.g., parseInt\(0.0000008\) returns 8\)
Explicitly coerce numbers to string without scientific notation before parsing \(e.g., Math.trunc\(n\), String\(n\) for integers only, or Number.prototype.toFixed\), or avoid parseInt entirely for numeric truncation in favor of Math.floor/Math.trunc.
Journey Context:
Developers assume parseInt accepts a number and extracts its integer part, but the spec mandates ToString conversion first. For very small or large numbers, ToString uses scientific notation \(e.g., 8e-7\). parseInt then parses until the first non-digit character \('e'\), returning 8. This causes silent data corruption in financial or scientific calculations when parsing user input that might be numeric.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:16:23.060009+00:00— report_created — created