Skip to content

linter: Incorrect no-loss-of-precision of '3e-308' #19988

@linkej-autodesk

Description

@linkej-autodesk

What version of Oxlint are you using?

1.51.0

What command did you run?

oxlint

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

No config

What happened?

const x = 3e-308; produces no-loss-of-precision. I think that's not what users would expect ( and it's inconsistent with eslint)

Consider the following demonstration

const x = 3e-308;                // oxlint warns, ESLint does not
console.log(x.toPrecision(17));  // "3.0000000000000002e-308", 16 correct decimal digits

const y = 0.1;                   // neither warns, even though this also has 16 correct digits
console.log(y.toPrecision(17));  // "0.10000000000000001", 

Now, using toPrecision(18) reveals that with 0.1, you get 17 precise digits, but with 3e-308 only 16, maybe that's why oxlint reports this. But as far as I can tell, doubles only guarantee 16 precise digits, and the literals specify only 1 digit, and that one is preserved exactly.

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions