Function __builtin_nanf [src]

returns a quiet NaN. Quiet NaNs have many representations; tagp is used to select one in an implementation-defined way. This implementation is based on the description for __builtin_nan provided in the GCC docs at https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fnan Comment is reproduced below: Since ISO C99 defines this function in terms of strtod, which we do not implement, a description of the parsing is in order. The string is parsed as by strtol; that is, the base is recognized by leading ‘0’ or ‘0x’ prefixes. The number parsed is placed in the significand such that the least significant bit of the number is at the least significant bit of the significand. The number is truncated to fit the significand field provided. The significand is forced to be a quiet NaN. If tagp contains any non-numeric characters, the function returns a NaN whose significand is zero. If tagp is empty, the function returns a NaN whose significand is zero.

Prototype

pub inline fn __builtin_nanf(tagp: []const u8) f32

Parameters

tagp: []const u8

Source

pub inline fn __builtin_nanf(tagp: []const u8) f32 { const parsed = std.fmt.parseUnsigned(c_ulong, tagp, 0) catch 0; const bits: u23 = @truncate(parsed); // single-precision float trailing significand is 23 bits return @bitCast(@as(u32, bits) | @as(u32, @bitCast(std.math.nan(f32)))); }