Skip to content

Print floats with the shortest digits that round-trip #93

Closed

Description

@dimensionscape

Float-to-string tries 15, 16 and 17 significant digits until the value reads back, which round-trips but is not always the shortest form: the smallest denormal prints 4.94065645841247e-324 (shortest: 5e-324), and large integral values use exponent form earlier than JS (1e+16 vs 10000000000000000). C++17 std::to_chars(double) gives the shortest round-trip digits on MSVC, libstdc++ and libc++, without a new dependency; the current loop can stay as the fallback where it is unavailable. The exponent and integer formatting rules Haxe code relies on (Std.string, string interpolation, Json) should stay as they are apart from the digit count.

Activity

  1. added a commit that references this issue on Oct 21, 2026
    aa4bc0e
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