| ... | ... | @@ -102,10 +102,16 @@ test "math.ldexp" { |
| 102 | 102 | try expect(ldexp(math.floatTrueMin(T), 0) > 0.0); |
| 103 | 103 | try expect(ldexp(math.floatTrueMin(T), -1) == 0.0); |
| 104 | 104 | |
| 105 | // Multiplications might flush the denormals to zero, esp. at |
| 106 | // runtime, so we manually construct the constants here instead. |
| 107 | const Z = std.meta.Int(.unsigned, @bitSizeOf(T)); |
| 108 | const EightTimesTrueMin = @bitCast(T, @as(Z, 8)); |
| 109 | const TwoTimesTrueMin = @bitCast(T, @as(Z, 2)); |
| 110 | |
| 105 | 111 | // subnormals -> subnormals |
| 106 | | try expect(ldexp(math.floatTrueMin(T), 3) == math.floatTrueMin(T) * 8); |
| 107 | | try expect(ldexp(math.floatTrueMin(T) * 8, -2) == math.floatTrueMin(T) * 2); |
| 108 | | try expect(ldexp(math.floatTrueMin(T) * 8, -3) == math.floatTrueMin(T)); |
| 112 | try expect(ldexp(math.floatTrueMin(T), 3) == EightTimesTrueMin); |
| 113 | try expect(ldexp(EightTimesTrueMin, -2) == TwoTimesTrueMin); |
| 114 | try expect(ldexp(EightTimesTrueMin, -3) == math.floatTrueMin(T)); |
| 109 | 115 | |
| 110 | 116 | // subnormals -> normals (+) |
| 111 | 117 | try expect(ldexp(math.floatTrueMin(T), fractional_bits) == math.floatMin(T)); |