| ... | @@ -843,3 +843,20 @@ test "compare undefined literal with comptime_int" { | ... | @@ -843,3 +843,20 @@ test "compare undefined literal with comptime_int" { |
| 843 | x = true; | 843 | x = true; |
| 844 | expect(x); | 844 | expect(x); |
| 845 | } | 845 | } |
| | 846 | |
| | 847 | test "signed zeros are represented properly" { |
| | 848 | const S = struct { |
| | 849 | fn doTheTest() void { |
| | 850 | inline for ([_]type{ f16, f32, f64, f128 }) |T| { |
| | 851 | const ST = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); |
| | 852 | var as_fp_val = -@as(T, 0.0); |
| | 853 | var as_uint_val = @bitCast(ST, as_fp_val); |
| | 854 | // Ensure the sign bit is set. |
| | 855 | expect(as_uint_val >> (@typeInfo(T).Float.bits - 1) == 1); |
| | 856 | } |
| | 857 | } |
| | 858 | }; |
| | 859 | |
| | 860 | S.doTheTest(); |
| | 861 | comptime S.doTheTest(); |
| | 862 | } |