mirror of
https://github.com/ziglang/zig.git
synced 2024-11-16 17:15:37 +00:00
std.fmt.parseHexFloat: clean up bitwise logic
* fold a couple separate operations into one * use const instead of var * naming conventions
This commit is contained in:
parent
7f024d6786
commit
c46f7588ce
@ -206,13 +206,11 @@ pub fn parseHexFloat(comptime T: type, s: []const u8) !T {
|
||||
// - we've truncated more than 0.5ULP (R=S=1)
|
||||
// - we've truncated exactly 0.5ULP (R=1 S=0)
|
||||
// Were are going to increase the mantissa (round up)
|
||||
var exactly_half = (mantissa & 0b11) == 0b10;
|
||||
var more_than_half = (mantissa & 0b11) == 0b11;
|
||||
const guard_bit_and_half_or_more = (mantissa & 0b110) == 0b110;
|
||||
mantissa >>= 2;
|
||||
var guardBit = mantissa & 1 == 1;
|
||||
exponent += 2;
|
||||
|
||||
if (guardBit and (exactly_half or more_than_half)) {
|
||||
if (guard_bit_and_half_or_more) {
|
||||
mantissa += 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user