diff options
| author | kkHAIKE <kkhaike@gmail.com> | 2022-09-19 15:39:56 +0800 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-10-13 13:11:13 +0200 |
| commit | d987bf859e6d8511abb49b258c4d764bd32acc8e (patch) | |
| tree | b8a0448ffea6b5a57f3e53bff46971a9ff424977 /src/value.zig | |
| parent | 3a9344d8fc757e6c771f689fce0db912e39115e9 (diff) | |
| download | zig-d987bf859e6d8511abb49b258c4d764bd32acc8e.tar.gz zig-d987bf859e6d8511abb49b258c4d764bd32acc8e.zip | |
Sema: add float128IntPartToBigInt to fix compare comptime float with int
Diffstat (limited to 'src/value.zig')
| -rw-r--r-- | src/value.zig | 17 |
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()); |
