# The two-digit lookup table that makes integer-to-string conversion 31% faster

Original title: Integer to String Conversion (2014)

> Hacker News story 50146417 · language: en · submitted 2026-10-18
> Web version: https://zeli.app/story/50146417
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 30 · by [jstrieb](<https://news.ycombinator.com/user?id=jstrieb>) · 💬 0
[original](<https://tia.mat.br/posts/2014/06/23/integer_to_string_conversion.html>) · [HN discussion](<https://news.ycombinator.com/item?id=50146417>)

## Summary

L. Pereira recounts optimizing integer-to-string conversion in Lwan, from snprintf to a naive reverse-and-divide method, then to a backward-writing approach. He admits committing an unmeasured change (lookup table to addition) that was actually 9% slower. Facebook's two-digit lookup table halves divisions and runs 31% faster, but licensing prevents its use in Lwan.

## Key quote

> However, I eventually did what one should always avoid when tinkering with this kind of thing: I've changed the array lookup to an addition, without measuring if it would perform better, and committed the code anyway. The lookup table is ~9% faster. Ouch!

---

## Cite

- Page: https://zeli.app/story/50146417
- Date: 2026-10-18
- Source: tia.mat.br (https://tia.mat.br/posts/2014/06/23/integer_to_string_conversion.html)
- Hacker News: https://news.ycombinator.com/item?id=50146417

## Other languages

- zh: https://zeli.app/zh/story/50146417 · markdown: https://zeli.app/zh/story/50146417.md
- ja: https://zeli.app/ja/story/50146417 · markdown: https://zeli.app/ja/story/50146417.md
- ko: https://zeli.app/ko/story/50146417 · markdown: https://zeli.app/ko/story/50146417.md
- de: https://zeli.app/de/story/50146417 · markdown: https://zeli.app/de/story/50146417.md
- es: https://zeli.app/es/story/50146417 · markdown: https://zeli.app/es/story/50146417.md
- ru: https://zeli.app/ru/story/50146417 · markdown: https://zeli.app/ru/story/50146417.md
