Skip to content

Add alternative to ryu#10986

Merged
sverker merged 2 commits intoerlang:masterfrom
sverker:sverker/erts/ryu-alternative
Apr 10, 2026
Merged

Add alternative to ryu#10986
sverker merged 2 commits intoerlang:masterfrom
sverker:sverker/erts/ryu-alternative

Conversation

@sverker
Copy link
Copy Markdown
Contributor

@sverker sverker commented Apr 8, 2026

What?

The implementation of float_to_list/binary(_, [short]).

Why?

To optionally avoid yet another embedded 3PP.

Limitations

  • Needs C++17
  • Currently not totally backward compatible with ryu's output format.

@sverker sverker self-assigned this Apr 8, 2026
@sverker sverker added feature team:VM Assigned to OTP team VM labels Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

CT Test Results

    3 files    136 suites   49m 55s ⏱️
1 670 tests 1 614 ✅ 56 💤 0 ❌
2 312 runs  2 238 ✅ 74 💤 0 ❌

Results for commit d1eafda.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@sverker sverker added the testing currently being tested, tag is used by OTP internal CI label Apr 9, 2026
@rickard-green
Copy link
Copy Markdown
Contributor

Could be good to document the configure option and its incompatibility here

Alternative implementation uses std::to_chars() in C++17 STL.

Configure defaults to ryu as currently the float string format sometimes
differ from ryu. Example:

ryu "1.0e4"
alt "10000.0"

The reason in this case is that std:to_chars() returns "10000"
and then we add ".0" and that makes it longer than "1.0e4".

ToDo:
It should be possible to mimic ryu and always choose the shortest
by doing string conversions to/from the scientific formats.

STL e-format: 1e+05  (no redundant '.', always exp sign, min exp 2 chars)
ryu e-format: 1.0e5  (always '.', no exp '+', no exp min size)
@sverker sverker force-pushed the sverker/erts/ryu-alternative branch from 7046a36 to d1eafda Compare April 9, 2026 21:32
@sverker sverker requested a review from rickard-green April 9, 2026 21:32
@sverker sverker merged commit b7ac43f into erlang:master Apr 10, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants