Function inf [src]
Alias for std.math.float.inf
Returns the inf value for a floating point Type.
Prototype
pub inline fn inf(comptime Type: type) Type Parameters
Type: type Example
test inf {
const inf_u16: u16 = 0x7C00;
const inf_u32: u32 = 0x7F800000;
const inf_u64: u64 = 0x7FF0000000000000;
const inf_u80: u80 = 0x7FFF8000000000000000;
const inf_u128: u128 = 0x7FFF0000000000000000000000000000;
try expectEqual(inf_u16, @as(u16, @bitCast(inf(f16))));
try expectEqual(inf_u32, @as(u32, @bitCast(inf(f32))));
try expectEqual(inf_u64, @as(u64, @bitCast(inf(f64))));
try expectEqual(inf_u80, @as(u80, @bitCast(inf(f80))));
try expectEqual(inf_u128, @as(u128, @bitCast(inf(f128))));
} Source
pub inline fn inf(comptime Type: type) Type {
const RuntimeType = switch (Type) {
else => Type,
comptime_float => f128, // any float type will do
};
return reconstructFloat(RuntimeType, floatExponentMax(RuntimeType) + 1, mantissaOne(RuntimeType));
}