# Exponent(inf) trouble

**URL:** <https://fortran-lang.discourse.group/t/exponent-inf-trouble/10860>\
**Category:** Help\
**Created:** [April 16, 2026, 4:22am UTC](https://fortran-lang.discourse.group/t/exponent-inf-trouble/10860 "2026-04-16T04:22:53Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![msz59](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@msz59](https://fortran-lang.discourse.group/u/msz59)\
**Post date:** [April 19, 2026, 7:36pm UTC](https://fortran-lang.discourse.group/t/exponent-inf-trouble/10860/21 "2026-04-19T19:36:13Z")

</div>

The significant bits in a NaN (except the leading bit distinguishing between quiet and signalling NaN) are called “payload”.  
This is what Perplexity.ai gave me for _How do NaN payloads work in IEEE 754?:_

=============================================

NaN payloads in IEEE 754 provide additional bits in the significand field of NaN values for diagnostic or application-specific data, beyond just signaling invalid operations. [en.wikipedia](https://en.wikipedia.org/wiki/NaN)

## NaN Structure

NaNs share the all-1s exponent with infinities but have a non-zero significand (fraction/mantissa).

- **Sign bit** : Ignored or application-defined (often 0).
- **Leading significand bit** : Distinguishes types.
  - Quiet NaN (qNaN): MSB=1 (propagates silently).
  - Signaling NaN (sNaN): MSB=0 (may raise exceptions if enabled).

- **Payload** : Remaining significand bits (e.g., 22 bits for single precision binary32, 51 for binary64 double). [stackoverflow](https://stackoverflow.com/questions/19800415/why-does-ieee-754-reserve-so-many-nan-values&rut=b6b1d8647be50f443175f243d7a4f98178b86a338ab8551814e4397e53111744)

| Format | Total Bits | Exponent | Sign + Type Bit | Payload Bits |
| --- | --- | --- | --- | --- |
| binary32 | 32 | 8 | 2 | 22 |
| binary64 | 64 | 11 | 2 | 51 |
| binary128 | 128 | 15 | 2 | 111 |

Example binary32 qNaN: `0 11111111 1xxxxxxxxxxxxxxx` (payload in x’s). [en.wikipedia](https://en.wikipedia.org/wiki/NaN)

## Payload Behavior

- **Propagation** : Operations with NaN return NaN, typically copying the input NaN’s payload (or preferring one if multiple). [discourse.llvm](https://discourse.llvm.org/t/semantics-of-nan/66729?page=2)
- **Ordering** : NaNs sort after numbers; among NaNs, by payload (lesser payload \< greater in IEEE 754-2008). [en.wikipedia](https://en.wikipedia.org/wiki/IEEE_754)
- **Uses** : Diagnostic codes (e.g., error origins), NaN-boxing (type-tagged non-floats in payloads, as in JavaScript engines), or proprietary data. [dan.corlan](http://dan.corlan.net/software/nan_payload/)

## Standard Operations (IEEE 754-2008/2019)

IEEE 754-2019 recommends `getPayload`, `setPayload`, `setPayloadSignaling` for payload access (required for new implementations). [englishwiki.en-us.nina](https://www.englishwiki.en-us.nina.az/NaN.html)

| Operation | Behavior |
| --- | --- |
| qNaN op anything | qNaN (payload preserved) |
| sNaN op non-NaN | qNaN (if no exception) |
| sNaN op sNaN | qNaN |
| Comparison with NaN | False (except != self) |

Payloads enhance NaN utility without altering core semantics, ensuring vast NaN space (~0.4% of values) isn’t wasted. Implementations vary (e.g., x86 may embed instruction addresses). [stackoverflow](https://stackoverflow.com/questions/19800415/why-does-ieee-754-reserve-so-many-nan-values&rut=b6b1d8647be50f443175f243d7a4f98178b86a338ab8551814e4397e53111744)

_Edited:_ As for `0**0` result, according to `englishwiki.en-us.nina` link above, also found [elsewhere](https://www.terpconnect.umd.edu/~petersd/460/ieee754.html), the standard (IEEE, I presume) provides several _power_ functions with different expected results:

- The standard `pow` function and the integer exponent `pown` function define `0 **0`, `1** (±∞)`, and `(±∞)**0` as 1.
- The `powr` function defines all three indeterminate forms as invalid operations and so returns NaN.

---

<div class="post-metadata">

**Author:** ![Harper](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@Harper](https://fortran-lang.discourse.group/u/Harper)\
**Post date:** [April 19, 2026, 9:25pm UTC](https://fortran-lang.discourse.group/t/exponent-inf-trouble/10860/22 "2026-04-19T21:25:02Z")

</div>

@urbanjost is of course right about `x0 **x0`. But `x** y` may not tend to 1 if x and y both tend to zero, but are not equal. If `y=c/log(x)` where c is a constant, the limit is exp(c). Then there’s `y=c/sqrt(abs(log(x)))` …

[Previous page](https://fortran-lang.discourse.group/t/exponent-inf-trouble/10860.md?page=1)
