nan#
Build a NaN, optionally carrying a payload.
Synopsis#
my $q = POSIX::nan(); # the platform's default NaN
my $p = POSIX::nan(42); # NaN carrying payload 42
What you get back#
A NaN whose low mantissa bits hold the payload, readable again with POSIX::getpayload. The payload is truncated to the 51 bits an IEEE double has room for.
Edge cases#
No argument yields the default NaN, which is not necessarily the zero payload on every platform.
The argument is a NUMBER, not a string of digits:
nan("0x2a")numifies to 0, andnan("42abc")to 42, exactly as any other numeric context would.A negative payload wraps rather than clamping, so
nan(-1)gives the all-ones payload.
Differences from upstream#
Payloads at or above 2**64 only: see nv_to_uv_c. Every payload an IEEE double can actually represent matches upstream exactly.