简体   繁体   中英

Why is zero not a subnormal number?

The IEEE-754 standard defines subnormal numbers such that the two zeros are explicitly excluded. What's the rationale for this decision, and does this mean that the performance penalty for subnormals does not apply to zero?

First of all, it's important to recognize that IEEE-754 is a standard for the behavior of conforming implementations. It talks about "what", not "how". It is not a guide on how to effectively implement that behavior, in software or in hardware. The fact that zero has the bit pattern and semantics of a subnormal is interesting and clearly not an accident but is not what the standard is here to talk about .

Second of all, a bit of history: subnormals are one of the weirder aspects of IEEE-754. Plenty of previous approaches to floating point didn't support them. To this day, the majority of 754 implementations either allow them to be toggled off, support them only through software fallbacks, or don't support them at all.

Subnormals were, and are, seen as a "last line of defense": You wouldn't generally intentionally use them as inputs, but having them available as outputs helps with the robustness of FP-using algorithms. Sterbenz's theorem (you can exactly subtract any two FP numbers which differ by less than a factor of two) is a good example of this. But the difficulty of efficiently implementing subnormal arithmetic was recognized at the time.

Needless to say, the number zero is pretty common. Operations involving zero are not done using the code/circuitry which supports subnormals, because that would be slow, and it's trivially easy to special-case zero inputs instead.

So, to sum up: Zero was not described as a "subnormal number" because the important practical aspects of subnormal numbers (ie the slowness) do not apply to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM