Floor and Ceil versus Denormals on CPU and GPU

Tiny numbers, huge meltdown: coders argue over whether computers should just call them zero

TLDR: The article shows that a tiny negative number should mathematically round down to -1, but some computers treat that almost-zero value as plain zero instead. In the comments, people split between “accuracy matters” and “just make it fast,” with some calling these edge-case numbers a long-running nightmare.

A seemingly microscopic math question on asawicki.info somehow turned into full comment-section theater: what should a computer do with a teeny-tiny negative number that’s almost zero, and should it become -1 when rounded down? The article walks through why the mathematical answer says yes, but real machines don’t always play nice. Some systems keep these absurdly small values, while others basically shrug and treat them as zero. For normal people, that sounds harmless. For programmers, apparently, it’s the kind of thing that can launch a miniature civil war.

The loudest reaction was pure pragmatism. One commenter warned that handling these near-zero values on a CPU can be painfully slow, recalling a dramatic 10x slowdown and suggesting many apps should just flip the “pretend it’s zero” switch and move on. That fed straight into the hottest mood in the thread: correctness vs speed. Another commenter pushed back on the article’s swipe at Nvidia, essentially asking, “Wait, why is doing it the right way too slow?” That turned the discussion from math trivia into a classic tech scandal: is this a smart shortcut, or a lazy cheat dressed up as performance?

And then came the ultimate roast. One community member basically said these weird tiny numbers are so cursed that even the people who invented them struggled with them. That line landed like a meme-worthy finishing move. The vibe? Half classroom, half cage match, with everyone agreeing on one thing: computers are somehow still finding new ways to be dramatic about numbers that are almost nothing.

Key Points

  • The article examines the result of applying `floor` to the negative subnormal 32-bit floating-point value `-1.175493930432748e-38` (`0x807FFFFD`).
  • It explains the behavior of `floor`, `ceil`, `trunc`, and `round`, emphasizing that they return floating-point results rather than integer conversions.
  • The post notes language-specific differences for halfway rounding: C/C++ round away from zero, HLSL rounds to nearest even, and GLSL leaves `round` implementation-dependent while providing `roundEven`.
  • By mathematical definition, the article states that `floor(-1.175493930432748e-38)` equals `-1.0` because the value lies between `-1` and `0`.
  • The article highlights that subnormal numbers may be preserved on some platforms or flushed to zero on others, which can affect function results despite tiny numerical differences.

Hottest takes

"extremely slow" — crote
"Why is implementing it correctly not performant?" — kevmo314
"Even their inventor had trouble writing correct code" — yosefk
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.