| author | |
| committer | |
| log | 227fb4875f5084cdb3436c40c4a08809bd3e4f50 |
| tree | e323903b66e7ac5c98935ae811d1467aecea69b9 |
| parent | 28383d4d985cd04c897f6b6a63bd2107d8e2a8e9 |
8 files changed, 22 insertions(+), 22 deletions(-)
lib/compiler_rt/comparef.zig+2-2| ... | ... | @@ -61,8 +61,8 @@ pub inline fn cmpf2(comptime T: type, comptime RT: type, a: T, b: T) RT { |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | pub inline fn cmp_f80(comptime RT: type, a: f80, b: f80) RT { |
| 64 | const a_rep = std.math.break_f80(a); | |
| 65 | const b_rep = std.math.break_f80(b); | |
| 64 | const a_rep = std.math.F80.fromFloat(a); | |
| 65 | const b_rep = std.math.F80.fromFloat(b); | |
| 66 | 66 | const sig_bits = std.math.floatMantissaBits(f80); |
| 67 | 67 | const int_bit = 0x8000000000000000; |
| 68 | 68 | const sign_bit = 0x8000; |
lib/compiler_rt/extendf.zig+1-1| ... | ... | @@ -131,7 +131,7 @@ pub inline fn extend_f80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeI |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | dst.exp |= sign; |
| 134 | return std.math.make_f80(dst); | |
| 134 | return dst.toFloat(); | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | test { |
lib/compiler_rt/extendxftf2.zig+1-1| ... | ... | @@ -18,7 +18,7 @@ fn __extendxftf2(a: f80) callconv(.C) f128 { |
| 18 | 18 | const dst_min_normal = @as(u128, 1) << dst_sig_bits; |
| 19 | 19 | |
| 20 | 20 | // Break a into a sign and representation of the absolute value |
| 21 | var a_rep = std.math.break_f80(a); | |
| 21 | var a_rep = std.math.F80.fromFloat(a); | |
| 22 | 22 | const sign = a_rep.exp & 0x8000; |
| 23 | 23 | a_rep.exp &= 0x7FFF; |
| 24 | 24 | var abs_result: u128 = undefined; |
lib/compiler_rt/subxf3.zig+2-2| ... | ... | @@ -8,8 +8,8 @@ comptime { |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | fn __subxf3(a: f80, b: f80) callconv(.C) f80 { |
| 11 | var b_rep = std.math.break_f80(b); | |
| 11 | var b_rep = std.math.F80.fromFloat(b); | |
| 12 | 12 | b_rep.exp ^= 0x8000; |
| 13 | const neg_b = std.math.make_f80(b_rep); | |
| 13 | const neg_b = b_rep.toFloat(); | |
| 14 | 14 | return a + neg_b; |
| 15 | 15 | } |
lib/compiler_rt/truncf.zig+1-1| ... | ... | @@ -121,7 +121,7 @@ pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t { |
| 121 | 121 | const dst_nan_mask = dst_qnan - 1; |
| 122 | 122 | |
| 123 | 123 | // Break a into a sign and representation of the absolute value |
| 124 | var a_rep = std.math.break_f80(a); | |
| 124 | var a_rep = std.math.F80.fromFloat(a); | |
| 125 | 125 | const sign = a_rep.exp & 0x8000; |
| 126 | 126 | a_rep.exp &= 0x7FFF; |
| 127 | 127 | a_rep.fraction &= 0x7FFFFFFFFFFFFFFF; |
lib/compiler_rt/trunctfxf2.zig+1-1| ... | ... | @@ -64,5 +64,5 @@ pub fn __trunctfxf2(a: f128) callconv(.C) f80 { |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | res.exp |= sign; |
| 67 | return math.make_f80(res); | |
| 67 | return res.toFloat(); | |
| 68 | 68 | } |
lib/std/math.zig+12-12| ... | ... | @@ -1720,20 +1720,20 @@ pub fn comptimeMod(num: anytype, comptime denom: comptime_int) IntFittingRange(0 |
| 1720 | 1720 | pub const F80 = struct { |
| 1721 | 1721 | fraction: u64, |
| 1722 | 1722 | exp: u16, |
| 1723 | }; | |
| 1724 | 1723 | |
| 1725 | pub fn make_f80(repr: F80) f80 { | |
| 1726 | const int = (@as(u80, repr.exp) << 64) | repr.fraction; | |
| 1727 | return @as(f80, @bitCast(int)); | |
| 1728 | } | |
| 1724 | pub fn toFloat(self: F80) f80 { | |
| 1725 | const int = (@as(u80, self.exp) << 64) | self.fraction; | |
| 1726 | return @as(f80, @bitCast(int)); | |
| 1727 | } | |
| 1729 | 1728 | |
| 1730 | pub fn break_f80(x: f80) F80 { | |
| 1731 | const int = @as(u80, @bitCast(x)); | |
| 1732 | return .{ | |
| 1733 | .fraction = @as(u64, @truncate(int)), | |
| 1734 | .exp = @as(u16, @truncate(int >> 64)), | |
| 1735 | }; | |
| 1736 | } | |
| 1729 | pub fn fromFloat(x: f80) F80 { | |
| 1730 | const int = @as(u80, @bitCast(x)); | |
| 1731 | return .{ | |
| 1732 | .fraction = @as(u64, @truncate(int)), | |
| 1733 | .exp = @as(u16, @truncate(int >> 64)), | |
| 1734 | }; | |
| 1735 | } | |
| 1736 | }; | |
| 1737 | 1737 | |
| 1738 | 1738 | /// Returns -1, 0, or 1. |
| 1739 | 1739 | /// Supports integer and float types and vectors of integer and float types. |
lib/std/math/nextafter.zig+2-2| ... | ... | @@ -61,7 +61,7 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T { |
| 61 | 61 | const integer_bit_mask = 1 << math.floatFractionalBits(f80); |
| 62 | 62 | const exponent_bits_mask = (1 << math.floatExponentBits(f80)) - 1; |
| 63 | 63 | |
| 64 | var x_parts = math.break_f80(x); | |
| 64 | var x_parts = math.F80.fromFloat(x); | |
| 65 | 65 | |
| 66 | 66 | // Bitwise increment/decrement the fractional part while also taking care to update the |
| 67 | 67 | // exponent if we overflow the fractional part. This might flip the integer bit; this is |
| ... | ... | @@ -88,7 +88,7 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T { |
| 88 | 88 | // set to cleared (if the old value was normal) or remained cleared (if the old value was |
| 89 | 89 | // subnormal), both of which are the outcomes we want. |
| 90 | 90 | |
| 91 | return math.make_f80(x_parts); | |
| 91 | return x_parts.toFloat(); | |
| 92 | 92 | } else { |
| 93 | 93 | const Bits = std.meta.Int(.unsigned, @bitSizeOf(T)); |
| 94 | 94 | var x_bits: Bits = @bitCast(x); |