Why this matters
Floating-point numbers have limited precision. Excessively precise numeric literals can lead to rounding errors and unexpected behavior in calculations.
Detect floating-point numbers with excessive precision. Overly precise numeric literals can cause rounding errors and unexpected behavior in calculations.
Floating-point numbers have limited precision. Excessively precise numeric literals can lead to rounding errors and unexpected behavior in calculations.
Side-by-side examples engineers can pattern-match during review.
var c = 999999999999999999999; // Not good, exceeds precision limits
var z = 1.12345678901234567; // Too precise, may lose accuracyvar a = 9; // Ok
var b = 999999999999999; // Ok, within safe limits
var w = 1.12e-4; // Ok
var y = 1.1234567890123; // Ok, precise but within limitsvar c = 999999999999999999999; // Not good, exceeds precision limits
var z = 1.12345678901234567; // Too precise, may lose accuracyvar a = 9; // Ok
var b = 999999999999999; // Ok, within safe limits
var w = 1.12e-4; // Ok
var y = 1.1234567890123; // Ok, precise but within limitsFrom the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.