Skip to content

Commit c46f758

Browse files
committed
std.fmt.parseHexFloat: clean up bitwise logic
* fold a couple separate operations into one * use const instead of var * naming conventions
1 parent 7f024d6 commit c46f758

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/std/fmt/parse_hex_float.zig

+2-4
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)