Skip to content

Incorrect string formatting for numbers larger than Int64.max (2^63 - 1) #113

@wadetregaskis

Description

@wadetregaskis

description (per CustomStringConvertible) seems to work fine, but of course doesn't produce localised outputs (as expected per its purpose). I want localised outputs, which is normally (for the built-in numeric types) done via the formatted(…) methods. These do exist on BigInt and BigUInt, but produce erroneous results at 2^63 and higher (9,223,372,036,854,775,808).

e.g. 2^63 renders as "9,223,372,036,854,775,807" (which is 2^63 - 1, which happens to be Int64.max).
e.g. 1e25 renders as "9,999,999,999,999,999,000,000,000".

It appears the formatting's precision is somehow limited to the first (highest-order) Int64 word, even though it does show the correct magnitude ("rounding" errors notwithstanding).

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