question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule idea: no imprecise number literals

See original GitHub issue

Please describe what the rule should do:

Flag number literals which do not precisely represent an IEEE754 double. Have an option to allow number literals that round to Infinity, such as 2e308, a somewhat common pattern to avoid referring to the Infinity global.

What category of rule is this? (place an “X” next to just one item)

  • Enforces code style
  • Warns about a potential error
  • Suggests an alternate way of doing something
  • Other (please specify:)

Provide 2-3 code examples that this rule will warn about:

0.1234567890123456789
12345678901234567890
12345678.901234567890
0xFFFFFFFFFFFFFFF

Why should this rule be included in ESLint (instead of a plugin)?

It’s a possible error that can affect all JavaScript users and can lead to logic bugs that are very hard to notice.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
not-an-aardvarkcommented, Apr 11, 2017

In practice, what’s the advantage of referring to 0.10000000000000000555 rather than 0.1? Does the system become more mathematically sound (e.g. by avoiding unexpected rounding errors)?

To me, 0.1 seems more readable than 0.10000000000000000555 because the former makes it clear that the literal is supposed to represent the mathematical value of 1/10, to the extent that floating-point precision can allow.

2reactions
rightfoldcommented, Apr 11, 2017

The rule should probably display the exact value of the literal, so that it can be substituted for by the programmer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extended Logic Programs - Department of Computing
Reducts, answer sets, splitting sets, etc, then work exactly as usual, except that an answer set will be a set of literals not...
Read more >
Plain Meaning Rule | Encyclopedia MDPI
The plain meaning rule, also known as the literal rule, is one of three rules of statutory construction traditionally applied by English courts....
Read more >
Objective C - Coding Rules
Assignments within sub-expressions are hard to spot and therefore make the code less readable. Ideally, sub-expressions should not have side-effects.
Read more >
A Decision Theory for Imprecise Probabilities
Introduction. How confident are you that someone exactly one hundred and forty- three days younger than you owns exactly nine bicycles? Give me...
Read more >
Abstract, Concrete, General and Specific Terms
Abstract terms refer to ideas or concepts; they have no physical referents. ... But we must understand how imprecise their meanings are, how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found