Skip to content
This repository was archived by the owner on Oct 10, 2019. It is now read-only.
This repository was archived by the owner on Oct 10, 2019. It is now read-only.

More precise parseInt and toString #86

Closed
@thejoshwolfe

Description

@thejoshwolfe

BigInt seems to be mimicking the parseInt and toString semantics of Number, but I don't understand why so much implementation-defined behavior is allowed for BigInt. For Number there are practical issues with loss of precision and exponential notation, but these are not concerns for BigInt.

This particular excerpt is concerning (from here relevant to BigInt through here):

However, if R is 10 and Z contains more than 20 significant digits, every significant digit after the 20th may be replaced by a 0 digit, at the option of the implementation; and if R is not 2, 4, 8, 10, 16, or 32, then mathInt may be an implementation-dependent approximation to the mathematical integer value that is represented by Z in radix-R notation.

It seems to defeat the purpose of arbitrary-precision BigInt if implementations can discard precision during parseInt.

And here's a concerning exceprt regarding toString (from here when radix is not 10):

The precise algorithm is implementation-dependent, however the algorithm should be a generalization of that specified in 3.1.4.1.

Why are we not precisely defining an abstract algorithm?

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