Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TOML allows large-magnitude integers that can't be represented exactly as JS numbers #28

Copy link
Copy link
@tomjakubowski

Description

@tomjakubowski
Issue body actions

The TOML spec says that numbers can lie in the range of 64-bit signed integers. This presents a problem for JavaScript implementations of TOML, since the entire range of 64-bit signed integers can't be represented exactly by JavaScript. In particular, only the closed range of integers [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER] can be represented exactly by the JavaScript number primitive.

To demonstrate that this is a problem for toml-node, check this out:

> require('toml').parse('max_safe = 9007199254740991\n' +
    'max_safe_plus_two = 9007199254740993')
{ max_safe: 9007199254740991,
  max_safe_plus_two: 9007199254740992 }

There are a few ways to deal with this problem (parse large ints as strings, depend on a BigInteger library for large ints, throw RangeErrors, among others). I don't have a strong opinion on which option is best, but I do think the library should address this issue in some way!

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.