From ec6ef86219578822fd32bbe2e5eb83b24ddfdca6 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 1 May 2020 13:33:46 -0400 Subject: [PATCH] fix off-by-one error in sizeInBaseUpperBound --- lib/std/math/big/int.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index 21f983c56f..8ee1474275 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -995,7 +995,7 @@ pub const Const = struct { /// TODO See if we can make this exact. pub fn sizeInBaseUpperBound(self: Const, base: usize) usize { const bit_count = @as(usize, @boolToInt(!self.positive)) + self.bitCountAbs(); - return (bit_count / math.log2(base)) + 1; + return (bit_count / math.log2(base)) + 2; } pub const ConvertError = error{