pub inline fn floatEpsAt(comptime T: type, x: T) T T: typex: T253
254
255
256
257
258
259
260
261
262
263pub inline fn floatEpsAt(comptime T: type, x: T) T {
switch (@typeInfo(T)) {
.float => |F| {
const U: type = @Int(.unsigned, F.bits);
const u: U = @bitCast(x);
const y: T = @bitCast(u ^ 1);
return @abs(x - y);
},
else => @compileError("floatEpsAt only supports floats"),
}
}