authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-31 20:57:05-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-31 20:59:32-07:00
logc46f7588cea98c48e6c7f637e13536378027e260
tree998df07db358b117250000eb539a08a021af3873
parent7f024d6786b690e7980d6e47d7ae70fa8528a0df

std.fmt.parseHexFloat: clean up bitwise logic

* fold a couple separate operations into one * use const instead of var * naming conventions

1 files changed, 2 insertions(+), 4 deletions(-)

lib/std/fmt/parse_hex_float.zig+2-4
......@@ -206,13 +206,11 @@ pub fn parseHexFloat(comptime T: type, s: []const u8) !T {
206206 // - we've truncated more than 0.5ULP (R=S=1)
207207 // - we've truncated exactly 0.5ULP (R=1 S=0)
208208 // Were are going to increase the mantissa (round up)
209 var exactly_half = (mantissa & 0b11) == 0b10;
210 var more_than_half = (mantissa & 0b11) == 0b11;
209 const guard_bit_and_half_or_more = (mantissa & 0b110) == 0b110;
211210 mantissa >>= 2;
212 var guardBit = mantissa & 1 == 1;
213211 exponent += 2;
214212
215 if (guardBit and (exactly_half or more_than_half)) {
213 if (guard_bit_and_half_or_more) {
216214 mantissa += 1;
217215 }
218216