<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-fastest-double-to-string-algorithm-you-ve-never-heard-of-pskmv50jg" -->

---
title: The fastest double-to-string algorithm you’ve never heard of
description: A deep technical exploration of yy, an obscure but extremely fast double-to-string (dtoa) algorithm found in the yyjson library. The algorithm belongs to the...
canonical: https://daily.dev/posts/the-fastest-double-to-string-algorithm-you-ve-never-heard-of-pskmv50jg
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The fastest double-to-string algorithm you’ve never heard of | daily.dev
og:description: A deep technical exploration of yy, an obscure but extremely fast double-to-string (dtoa) algorithm found in the yyjson library. The algorithm belongs to the...
og:url: https://daily.dev/posts/the-fastest-double-to-string-algorithm-you-ve-never-heard-of-pskmv50jg
og:image: https://api.daily.dev/og/posts/pSkmV50jG.png
og:image:alt: The fastest double-to-string algorithm you’ve never heard of
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The fastest double-to-string algorithm you’ve never heard of

**[Lobsters](https://daily.dev/sources/lobsters)** · 6 min read · 4 upvotes · 0 comments

## Summary

A deep technical exploration of yy, an obscure but extremely fast double-to-string (dtoa) algorithm found in the yyjson library. The algorithm belongs to the Schubfach family but achieves its speed by using only one multiplication by a precomputed power of 10, versus two or three in classic Schubfach. The post visualizes the algorithm using the compact E4M3 8-bit floating-point format, walks through its four candidate decimal values and three predicates, and dissects a boundary case (encoding 116) that appears to be a bug but is actually a deliberate fixed-point truncation correction. An interactive HTML explorer is provided to step through every E4M3 encoding.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://vitaut.net/posts/2026/yy-dtoa>

## Questions this post answers

### What makes the yy double-to-string algorithm from yyjson faster than classic Schubfach?

It needs only one multiplication by a precomputed power of 10, versus the two or three multiplications classic Schubfach requires. This is because the half-ulp bound reuses the same scaled significand instead of computing separate multiplications for the significand and its rounding bounds, saving what would otherwise be two extra 192-bit multiplications.

_Developers optimizing float serialization can compare dtoa algorithm tradeoffs like this one on daily.dev._

### What is the E4M3 floating-point format used for?

E4M3 is an 8-bit floating-point format with 1 sign bit, 4 exponent bits, 3 significand bits, and a bias of 7, used for low-precision AI inference on recent GPUs. Its small 256-value encoding space makes it useful for exhaustively visualizing floating-point-to-decimal conversion algorithms that would otherwise be hard to inspect at full double precision.

_Anyone tracking low-precision formats for GPU inference can follow number-format deep dives on daily.dev._

### Why does the yy algorithm sometimes emit a longer decimal than the shortest possible round-trip representation?

At encoding 116 in E4M3, yy's fixed-point predicate evaluates one LSB short of the threshold needed to pick the shorter decimal, due to a table value that is floored (truncated) when packed into the narrower Q4.4 working word. A correction term in the predicate's threshold compensates for that truncation, so the comparison still ties correctly and yy emits the proper output rather than an actual bug.

_Engineers debugging edge cases in numeric formatting algorithms can dig into examples like this on daily.dev._

## Similar posts on daily.dev

- [Faster double-to-string conversion](https://daily.dev/posts/faster-double-to-string-conversion-it911wvtz) · Hacker News · 1 upvotes · 0 comments
- [Engineering High-Performance Parsers with Data-Oriented Design](https://daily.dev/posts/engineering-high-performance-parsers-with-data-oriented-design-r1apuldsa) · Lobsters · 2 upvotes · 0 comments
- [research\!rsc: Floating-Point Printing and Parsing Can Be Simple And Fast \(Floating Point Formatting, Part 3\)](https://daily.dev/posts/research-rsc-floating-point-printing-and-parsing-can-be-simple-and-fast-floating-point-formatting--hnut6ahzn) · research\!rsc · 0 upvotes · 0 comments
- [Ruby Floats: When 2.6x Faster Is Actually Slower](https://daily.dev/posts/ruby-floats-when-2-6x-faster-is-actually-slower-e5wbxhxja) · RUBYLAND · 0 upvotes · 0 comments
- [How To Make a Fast Dynamic Language Interpreter](https://daily.dev/posts/how-to-make-a-fast-dynamic-language-interpreter-ax510brkl) · Hacker News · 0 upvotes · 0 comments

---

Tags: [#general-programming](https://daily.dev/tags/general-programming), [#c](https://daily.dev/tags/c), [#algorithms](https://daily.dev/tags/algorithms)

[View this post on daily.dev](https://daily.dev/posts/the-fastest-double-to-string-algorithm-you-ve-never-heard-of-pskmv50jg)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"The fastest double-to-string algorithm you’ve never heard of","url":"https://daily.dev/posts/the-fastest-double-to-string-algorithm-you-ve-never-heard-of-pskmv50jg","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-fastest-double-to-string-algorithm-you-ve-never-heard-of-pskmv50jg"},"datePublished":"2026-08-12T04:13:45.815Z","dateModified":"2026-09-14T08:56:40.683Z","description":"A deep technical exploration of yy, an obscure but extremely fast double-to-string (dtoa) algorithm found in the yyjson library. The algorithm belongs to the...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/78f0dd3966edf12632c62d4194e280d6?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/78f0dd3966edf12632c62d4194e280d6?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Lobsters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Lobsters","logo":"https://media.daily.dev/image/upload/s--tl8v_Fku--/f_auto,t_logo/v1698841318/logos/lobste.jpg","url":"https://daily.dev/sources/lobsters"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/the-fastest-double-to-string-algorithm-you-ve-never-heard-of-pskmv50jg","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"general-programming,c,algorithms","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Lobsters","item":"https://daily.dev/sources/lobsters"},{"@type":"ListItem","position":3,"name":"The fastest double-to-string algorithm you’ve never heard of"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/the-fastest-double-to-string-algorithm-you-ve-never-heard-of-pskmv50jg#faq","mainEntity":[{"@type":"Question","name":"What makes the yy double-to-string algorithm from yyjson faster than classic Schubfach?","acceptedAnswer":{"@type":"Answer","text":"It needs only one multiplication by a precomputed power of 10, versus the two or three multiplications classic Schubfach requires. This is because the half-ulp bound reuses the same scaled significand instead of computing separate multiplications for the significand and its rounding bounds, saving what would otherwise be two extra 192-bit multiplications. Developers optimizing float serialization can compare dtoa algorithm tradeoffs like this one on daily.dev."}},{"@type":"Question","name":"What is the E4M3 floating-point format used for?","acceptedAnswer":{"@type":"Answer","text":"E4M3 is an 8-bit floating-point format with 1 sign bit, 4 exponent bits, 3 significand bits, and a bias of 7, used for low-precision AI inference on recent GPUs. Its small 256-value encoding space makes it useful for exhaustively visualizing floating-point-to-decimal conversion algorithms that would otherwise be hard to inspect at full double precision. Anyone tracking low-precision formats for GPU inference can follow number-format deep dives on daily.dev."}},{"@type":"Question","name":"Why does the yy algorithm sometimes emit a longer decimal than the shortest possible round-trip representation?","acceptedAnswer":{"@type":"Answer","text":"At encoding 116 in E4M3, yy's fixed-point predicate evaluates one LSB short of the threshold needed to pick the shorter decimal, due to a table value that is floored (truncated) when packed into the narrower Q4.4 working word. A correction term in the predicate's threshold compensates for that truncation, so the comparison still ties correctly and yy emits the proper output rather than an actual bug. Engineers debugging edge cases in numeric formatting algorithms can dig into examples like this on daily.dev."}}]}
```

