| ... | @@ -103,7 +103,7 @@ fn convertRepr(comptime T: type, n: FloatRepr) T { | ... | @@ -103,7 +103,7 @@ fn convertRepr(comptime T: type, n: FloatRepr) T { |
| 103 | s.d1 = @truncate(u32, n.mantissa >> 32); | 103 | s.d1 = @truncate(u32, n.mantissa >> 32); |
| 104 | s.d2 = 0; | 104 | s.d2 = 0; |
| 105 | | 105 | |
| 106 | var binary_exponent: u64 = 92; | 106 | var binary_exponent: i32 = 92; |
| 107 | var exp = n.exponent; | 107 | var exp = n.exponent; |
| 108 | | 108 | |
| 109 | while (exp > 0) : (exp -= 1) { | 109 | while (exp > 0) : (exp -= 1) { |
| ... | @@ -161,7 +161,7 @@ fn convertRepr(comptime T: type, n: FloatRepr) T { | ... | @@ -161,7 +161,7 @@ fn convertRepr(comptime T: type, n: FloatRepr) T { |
| 161 | } else if (binary_exponent < 1) { | 161 | } else if (binary_exponent < 1) { |
| 162 | break :blk if (n.negative) f64_minus_zero else f64_plus_zero; | 162 | break :blk if (n.negative) f64_minus_zero else f64_plus_zero; |
| 163 | } else if (s.d2 != 0) { | 163 | } else if (s.d2 != 0) { |
| 164 | const binexs2 = u64(binary_exponent) << 52; | 164 | const binexs2 = @intCast(u64, binary_exponent) << 52; |
| 165 | const rr = (u64(s.d2 & ~mask28) << 24) | ((u64(s.d1) + 128) >> 8) | binexs2; | 165 | const rr = (u64(s.d2 & ~mask28) << 24) | ((u64(s.d1) + 128) >> 8) | binexs2; |
| 166 | break :blk if (n.negative) rr | (1 << 63) else rr; | 166 | break :blk if (n.negative) rr | (1 << 63) else rr; |
| 167 | } else { | 167 | } else { |
| ... | @@ -415,6 +415,7 @@ test "fmt.parseFloat" { | ... | @@ -415,6 +415,7 @@ test "fmt.parseFloat" { |
| 415 | if (T != f16) { | 415 | if (T != f16) { |
| 416 | expect(approxEq(T, try parseFloat(T, "123142.1"), 123142.1, epsilon)); | 416 | expect(approxEq(T, try parseFloat(T, "123142.1"), 123142.1, epsilon)); |
| 417 | expect(approxEq(T, try parseFloat(T, "-123142.1124"), T(-123142.1124), epsilon)); | 417 | expect(approxEq(T, try parseFloat(T, "-123142.1124"), T(-123142.1124), epsilon)); |
| | 418 | expect(approxEq(T, try parseFloat(T, "0.7062146892655368"), T(0.7062146892655368), epsilon)); |
| 418 | } | 419 | } |
| 419 | } | 420 | } |
| 420 | } | 421 | } |