floatEpsAt
Returns the local epsilon of floating point type T.
Function parameters
Parameters
- T:type
- x:T
Functions in this namespace
Functions
- floatExponentBits
- Returns the number of bits in the exponent of floating point type T.
- floatMantissaBits
- Returns the number of bits in the mantissa of floating point type T.
- floatFractionalBits
- Returns the number of fractional bits in the mantissa of floating point type T.
- floatExponentMin
- Returns the minimum exponent that can represent
- floatExponentMax
- Returns the maximum exponent that can represent
- floatTrueMin
- Returns the smallest subnormal number representable in floating point type T.
- floatMin
- Returns the smallest normal number representable in floating point type T.
- floatMax
- Returns the largest normal number representable in floating point type T.
- floatEps
- Returns the machine epsilon of floating point type T.
- floatEpsAt
- Returns the local epsilon of floating point type T.
- inf
- Returns the inf value for a floating point `Type`.
- nan
- Returns the canonical quiet NaN representation for a floating point `Type`.
- snan
- Returns a signalling NaN representation for a floating point `Type`.
Source
Implementation
pub inline fn floatEpsAt(comptime T: type, x: T) T {
switch (@typeInfo(T)) {
.float => |F| {
const U: type = @Type(.{ .int = .{ .signedness = .unsigned, .bits = F.bits } });
const u: U = @bitCast(x);
const y: T = @bitCast(u ^ 1);
return @abs(x - y);
},
else => @compileError("floatEpsAt only supports floats"),
}
}