aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/value.zig b/src/value.zig
index 01df65a715..7a0636dda0 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -1999,6 +1999,11 @@ pub const Value = extern union {
}
return true;
},
+ .float_16 => if (std.math.isNan(lhs.castTag(.float_16).?.data)) return op != .neq,
+ .float_32 => if (std.math.isNan(lhs.castTag(.float_32).?.data)) return op != .neq,
+ .float_64 => if (std.math.isNan(lhs.castTag(.float_64).?.data)) return op != .neq,
+ .float_80 => if (std.math.isNan(lhs.castTag(.float_80).?.data)) return op != .neq,
+ .float_128 => if (std.math.isNan(lhs.castTag(.float_128).?.data)) return op != .neq,
else => {},
}
return (try orderAgainstZeroAdvanced(lhs, sema_kit)).compare(op);
@@ -3596,6 +3601,18 @@ pub const Value = extern union {
};
}
+ /// Returns true if the value is a floating point type and is infinite. Returns false otherwise.
+ pub fn isInf(val: Value) bool {
+ return switch (val.tag()) {
+ .float_16 => std.math.isInf(val.castTag(.float_16).?.data),
+ .float_32 => std.math.isInf(val.castTag(.float_32).?.data),
+ .float_64 => std.math.isInf(val.castTag(.float_64).?.data),
+ .float_80 => std.math.isInf(val.castTag(.float_80).?.data),
+ .float_128 => std.math.isInf(val.castTag(.float_128).?.data),
+ else => false,
+ };
+ }
+
pub fn floatRem(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, target: Target) !Value {
if (float_type.zigTypeTag() == .Vector) {
const result_data = try arena.alloc(Value, float_type.vectorLen());