<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/optimize-the-common-cases-d9ueelqrp" -->

---
title: Optimize the common cases | daily.dev
description: When formatting numbers in Rust, adding fast paths for small values (-99 to 99) can dramatically reduce latency. Using hard-coded branches for single-digit and...
canonical: https://daily.dev/posts/optimize-the-common-cases-d9ueelqrp
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Optimize the common cases | daily.dev
og:description: When formatting numbers in Rust, adding fast paths for small values (-99 to 99) can dramatically reduce latency. Using hard-coded branches for single-digit and...
og:url: https://daily.dev/posts/optimize-the-common-cases-d9ueelqrp
og:image: https://api.daily.dev/og/posts/d9ueelQrp.png
og:image:alt: Optimize the common cases
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.

# Optimize the common cases

**[Sylvain Kerkour](https://daily.dev/sources/kerkour)** · 1 min read · 0 upvotes · 0 comments

## Summary

When formatting numbers in Rust, adding fast paths for small values (-99 to 99) can dramatically reduce latency. Using hard-coded branches for single-digit and two-digit cases in the stdx/format_number library brings formatting time from 2–10 nanoseconds down to ~700 picoseconds — under a nanosecond — by bypassing loop machinery and SIMD logic entirely.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://kerkour.com/common-cases-optimization>

## Questions this post answers

### How fast can Rust format small integers like single or two-digit numbers?

With dedicated fast paths for single-digit and two-digit numbers, Rust can format integers in the -99 to 99 range in approximately 700 picoseconds — under one nanosecond. Without these branches, even SIMD-accelerated number formatting takes 2–10 nanoseconds. The optimization works by bypassing loop machinery entirely and using a precomputed lookup table for two-digit values.

_Rust developers squeezing nanoseconds out of hot paths share techniques like these on daily.dev._

## Similar posts on daily.dev

- [Faster floating point math with Rust’s new API](https://daily.dev/posts/faster-floating-point-math-with-rust-s-new-api-zyoed6fm9) · Lobsters · 0 upvotes · 0 comments
- [Rust language adds algebraic floating-point methods](https://daily.dev/posts/rust-language-adds-algebraic-floating-point-methods-jimyxkos8) · InfoWorld · 1 upvotes · 0 comments
- [&&&&&&&&&&&&&&str](https://daily.dev/posts/str-ek7vtalze) · Lobsters · 0 upvotes · 0 comments

---

Tags: [#performance](https://daily.dev/tags/performance), [#rust](https://daily.dev/tags/rust)

[View this post on daily.dev](https://daily.dev/posts/optimize-the-common-cases-d9ueelqrp)

```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":"Optimize the common cases","url":"https://daily.dev/posts/optimize-the-common-cases-d9ueelqrp","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/optimize-the-common-cases-d9ueelqrp"},"datePublished":"2026-08-11T08:55:29.630Z","dateModified":"2026-08-11T09:39:49.975Z","description":"When formatting numbers in Rust, adding fast paths for small values (-99 to 99) can dramatically reduce latency. Using hard-coded branches for single-digit and...","image":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","thumbnailUrl":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","isAccessibleForFree":true,"articleSection":"Sylvain Kerkour","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":"Sylvain Kerkour","logo":"https://media.daily.dev/image/upload/s--3ngWt4Yp--/f_auto,q_auto/v1786438308/logos/kerkour?_a=BAMAMicg0","url":"https://daily.dev/sources/kerkour"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/optimize-the-common-cases-d9ueelqrp","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"performance,rust","timeRequired":"PT1M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Sylvain Kerkour","item":"https://daily.dev/sources/kerkour"},{"@type":"ListItem","position":3,"name":"Optimize the common cases"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/optimize-the-common-cases-d9ueelqrp#faq","mainEntity":[{"@type":"Question","name":"How fast can Rust format small integers like single or two-digit numbers?","acceptedAnswer":{"@type":"Answer","text":"With dedicated fast paths for single-digit and two-digit numbers, Rust can format integers in the -99 to 99 range in approximately 700 picoseconds — under one nanosecond. Without these branches, even SIMD-accelerated number formatting takes 2–10 nanoseconds. The optimization works by bypassing loop machinery entirely and using a precomputed lookup table for two-digit values. Rust developers squeezing nanoseconds out of hot paths share techniques like these on daily.dev."}}]}
```

