Skip to content

Commit d79325b

Browse files
Fix getNaNPayload: Add NaN precondition and update ddocs (#10901)
1 parent 5f8a36f commit d79325b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

std/math/operations.d

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ real NaN(ulong payload) @trusted pure nothrow @nogc
158158
* For 80-bit or 128-bit reals, it is 0x3FFF_FFFF_FFFF_FFFF.
159159
*/
160160
ulong getNaNPayload(real x) @trusted pure nothrow @nogc
161+
in
162+
{
163+
// Precondition: Input must be NaN
164+
import std.math.traits : isNaN;
165+
assert(isNaN(x), "getNaNPayload called on a non-NaN value");
166+
}
167+
do
161168
{
162169
import std.math.traits : floatTraits, RealFormat;
163170

0 commit comments

Comments
 (0)