Tech News
← Home  ·  All topics

Integer To String

1 GoKawiil brief on this topic

Lwan author details integer-to-string optimizations in 2014 blog post

The 2014 post traces how the Lwan web server's integer-to-string conversion evolved from using snprintf() to a naive divide-and-modulus algorithm that built digits in reverse and then flipped the string. The author then replaced it with a version that writes digits directly into a buffer from the end backwards, avoiding the separate string-reversal step and using a buffer sized via a trick based on multiplying sizeof(int) by three.