Skip to content

Numeric literals and Number() with exponents > 308 or < -324 ignore the significand decimal shift #5320

Open

Description

@trackoor

Numeric literals and Number(string) check whether the explicit exponent exceeds 308 or -324 before adding the decimal offset from the significand's digits, prematurely returning Infinity or 0. In ecma_utf8_string_to_number, exponent_sign * exponent is compared against NUMBER_MAX_DECIMAL_EXPONENT (308) and NUMBER_MIN_DECIMAL_EXPONENT (-324) inside the exponent loop before decimal_exponent is added.

JerryScript revision

v3.0.0 (b7069350c)

Build platform

macOS 26.3 (Darwin 25.3.0 arm64)

Build steps
tools/build.py --clean --debug
Test case
print(0.1e309);
print(50e-325);
print(Number("100e-325"));
Execution steps
build/bin/jerry testcase.js
Output
Infinity
0
0
Expected behavior
1e+308
5e-324
1e-323

V8, SpiderMonkey, and JavaScriptCore print 1e+308, 5e-324, and 1e-323 per ECMA-262 StringNumericValue.

Credit: https://ucsbplse.github.io/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions