HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
ulfjack
ryu
C++2018–2025
ulfjack / ryu

ryu

Converts floating point numbers to decimal strings

17Distinct people
21Mentions
0Explicit recommenders
1.4KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Converts floating point numbers to decimal strings

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 12:54:37 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year21 dated mentions

Observed mentions: 2018-07-28 12:55:32 UTC to 2025-09-12 14:57:42 UTC.

02462018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 7 mentions; 3 submissions, 4 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 4 mentions; 1 submissions, 3 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments20212022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2025

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC734
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC110
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC413
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC202
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC202
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC202
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC202

What Hacker News says

21 sources
> I wonder if there is a more efficient way to determine that shortest representation rather than running printf/scanf in a loop? Yes, just `printf("%f", ...);` will get you that. The actual algorithms to do the float->string conversion are quite complicated. Here is a recent pretty good one: https://github.com/ulfjack/ryu I think there's been an even more recent one that is even more efficient than Ryu but I don't remember the name.
In Float Exposed
A latency improvement would be to have digitCountThresholds be indexed by the lzcnt, instead of the result of the other LUT. Increases the size of that lookup table from 160B to 512B though. Funnily enough I've had this approach in a local copy of Ryu when I was working on cutting it down for my purposes. Unfortunately whatever ended up public had cut this out too. edit: some chat messages of me at [0]. Some previous unrelated discussion found at [1]. [0]: https://app.element.io/#/room/#bqn:matrix.org/$KKIK86x0tygAf... (arbitrarily capped at 18 digits because Ryu didn't need more) [1]: https://github.com/ulfjack/ryu/issues/34
In Optimizing uint64_t Digit Counting: A Method that Beats Lemire's by up to 143%
I believe the impl you link to is not fully standards compliant, and has an approximate soln. MSFT's one is totally standards compliant and it is a very different beast: https://github.com/microsoft/STL/blob/main/stl/inc/charconv Apart from various nuts and bolts optimizations (eg not using locales, better cache friendless, etc...) it also uses a novel algorithm which is an order of magnitude quicker for many floating points tasks (https://github.com/ulfjack/ryu). If you actually want to learn about this, then watch the video I linked earlier.
In C++ String Conversion: Exploring std:from_chars in C++17 to C++26
> Google put in significant engineering effort into "Ryu", a parsing library for double-precision floating point numbers: https://github.com/ulfjack/ryu It's not a parsing library, but a printing one, i.e., double -> string. https://github.com/fastfloat/fast_float is a parsing library, i.e., string -> double, not by Google though, but was indeed motivated by parsing JSON fast https://lemire.me/blog/2020/03/10/fast-float-parsing-in-prac...
In Parquet: An efficient, binary file format for table data
> There isn't really a CSV standard that defines the precise grammar of CSV. Did you read the link going to a page literally titled: "Parsing JSON is a Minefield."? JSON has a "precise" grammar intended to be human readable. The end result is a mess, vulnerable to attacks due to dissimilarities between different implementations. Google put in significant engineering effort into "Ryu", a parsing library for double-precision floating point numbers: https://github.com/ulfjack/ryu Why bother, you ask? Why would anyone bother to make floating point number parsing super efficient? JSON.
In Parquet: An efficient, binary file format for table data
Apparently exact minimal float-to-string conversion is more recent than I thought, and many languages used to print more (Python?) or less (PHP) decimal digits than necessary to uniquely identify the bit pattern. Python correctly prints 46000.80 + 553.04 as 46553.840000000004, but I don't know if it ever prints more digits than needed. One recent algorithm for printing floats exactly is https://github.com/ulfjack/ryu, though I'm unaware what's the state-of-the-art (https://github.com/jk-jeon/dragonbox claims to be a benchmark and the best algorithm).
In I still love PHP and JavaScript
> If you need to generate basic shapes it's fairly straightforward. You'd think so. While integrating TeX into my editor[0], using JMathTeX[1] as a starting point, I wanted to convert font glyphs to vector paths. At the time, every Java-based SVG renderer (Batik, JFreeSVG, SVG Salamander) suffered from the exact same performance problem: they all used Java's DecimalFormat class to convert floating point numbers to strings. These strings were then concatenated as paths into the output document. Sometimes the strings were re-copied numerous times because of buffer re-allocations and other reasons. (Part 5 of my series[2] on developing a TeX-oriented text editor covers this in depth.) To get great performance---in Java, at least---even for basic shapes requires a sufficiently large, reusable buffer that doesn't incur memory re-allocations an
Read the rest
d an efficient algorithm to convert floats to strings---such as Ryu[3]. See my implementation that converts glyph paths to vector paths for details[4]. With these two changes I was able to improve upon JFreeSVG's implementation four-fold. [0]: https://github.com/DaveJarvis/keenwrite (my editor) [1]: https://github.com/DaveJarvis/JMathTeX/ (my fork) [2]: https://bell-sw.com/announcements/2020/11/02/TeXnical-Writin... (my blog series) [3]: https://github.com/ulfjack/ryu [4]: https://github.com/DaveJarvis/JMathTeX/blob/d2d678717505765b...
In SVG: The Good, the Bad and the Ugly
Performance in the opposite direction is also useful; the Ryū algorithm[0] is a fast float-to-string conversion that I've used recently to great effect[1]. Namely, to convert path information from glyphs into vector graphics for a minimal math-oriented Java-based TeX implementation[2]. The result is code that converts 1,000 simple formulas as strings into individual SVG documents in under 600 milliseconds on newish hardware. [0]: https://github.com/ulfjack/ryu/blob/master/README.md [1]: https://news.ycombinator.com/item?id=17633182 [2]: https://github.com/DaveJarvis/JMathTeX/blob/master/README.md
In Parsing floats in C++: benchmarking strtod vs. from_chars
erthink·Feb 4, 2020Submission

Compact and fast double-to-string conversion

Ryu algorithm by Ulf Adams (https://github.com/ulfjack/ryu) known to fastest in much cases, especially for short string representations. However, I would like to draw attention to my own speed-competing but more compact GRISU-based implementation. Briefly, about this implementation: 1. it is a GRUSU-based, but not exactly the GRISU2; 2. for now produces only a raw ASCII representation, e.g. -22250738585072014e-324 without dot and '\0' at the end; 3. compared to Ryu, it significantly less code size and spends less clock cycles per digit, but is slightly inferior in a whole because generates a longer ASCII representation. Now I would like to get feedback, assess how much this is in demand and collect suggestions for further improvements. For instance, I think that it is reasonable to implement conversion with a specified precision (i.e., wi
Read the rest
th a specified number of digits), but not provide a printf-like interface. The benchmark source code: https://github.com/leo-yuriev/dtoa-benchmark The d2a() implementation: https://github.com/leo-yuriev/erthink/blob/master/erthink_d2a.h The test source code: https://github.com/leo-yuriev/erthink/blob/master/test/d2a.cxx Any suggestions are welcome!
4 points · Open discussion

Showing the 15 most recent of 21 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.