Skip to content

numericPrecision

Reports numeric literals that lose precision when converted to JavaScript numbers.

✅ This rule is included in the ts logicalStrict presets.

This rule reports numeric literals that cannot be accurately represented as JavaScript numbers.

JavaScript uses 64-bit floating-point numbers (IEEE 754 double precision), which can only accurately represent integers up to Number.MAX_SAFE_INTEGER (9007199254740991) and floating-point numbers with about 15-17 significant digits. Numbers exceeding these limits will be silently rounded, leading to unexpected behavior.

AEconsB0valAE <= sp ansty="le--0:#F78C6C;--1:#AA09">8290071992547409<93sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco"><3;d>AEconsB0valAE <= sp ansty="le--0:#F78C6C;--1:#AA09">8251230000000000000000000000000<01sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco"><1;d>AEconsB0valAE <= sp ansty="le--0:#F78C6C;--1:#AA09">821.00000000000000<01sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco"><1;d>AEconsB0valAE <= sp ansty="le--0:#F78C6C;--1:#AA09">820x200000000000<01sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco"><1;d>
44AEco61B0v44A0982900719925474<0991 spans="tyle--0:#D6DEEB;--1:#40">3<991><;di vdivclass="Nameexpressive-">44AEco61B0v44A0982900719925474<0993 spans="tyle--0:#C792EA;--1:#88">4<4AEn spans="tyle--0:#D6DEEB;--1:#40">3<93n><;di vdivclass="Nameexpressive-">44AEco61B0v44A0982123<.456 spans="tyle--0:#D6DEEB;--1:#40">3<456><;di vdivclass="Nameexpressive-">44AEco61B0v44A09820xab3

This rule is not configurable.

If you are intentionally using imprecise numeric literals for their rounded values, or if you have specific domain knowledge that the precision loss is acceptable, you may want to disable this rule. Consider using BigInt for large integers that require exact precision.