`7.120236347223045e-307` is stringified as `7.1202363472230444e-307`

Open
#449 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 5 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
c, javascript
Domain
compilers

Research direction

Start by reproducing the value and its stringification in the qjs REPL, comparing the two decimal forms shown in the issue. Trace the JavaScript number stringification path and add coverage for this exact value; done means qjs emits the shorter representation used by the other engines while preserving correct round-tripping.

Written by the indexing model from the issue text.

Description

I am testing out using quickjs to fuzz typescript-go's JS number implementation more quickly than shelling out to Node.js (by way of https://gitlab.com/cznic/quickjs to avoid cgo, not important for this issue).

One thing showed up in fuzzing. The number value 7.120236347223045e-307 is stringified by quickjs as 7.1202363472230444e-307:

qjs > 7.120236347223045e-307
7.1202363472230444e-307
qjs > 7.1202363472230444e-307
7.1202363472230444e-307

Which seems to be a longer encoding of the same value (based on comparing the bits of both).

V8, SpiderMonkey, JSC, etc, give the shorter encoding:

# V8
d8> 7.120236347223045e-307
7.120236347223045e-307
d8> 7.1202363472230444e-307
7.120236347223045e-307
# spidermonkey
js> 7.120236347223045e-307
7.120236347223045e-307
js> 7.1202363472230444e-307
7.120236347223045e-307
js> 
# javascriptcore
>>> 7.120236347223045e-307
7.120236347223045e-307
>>> 7.1202363472230444e-307
7.120236347223045e-307
Dominant language
C
Stars
11.1k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bellard/quickjs

All issues in bellard/quickjs

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.