diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2024-08-06 11:22:37 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2024-08-16 15:22:55 -0400 |
| commit | ef11bc9899002620d67cfce9c79b6c0dc0f5ea61 (patch) | |
| tree | 7b05fe17340c06e4c40c45ebe249361c0c281c72 /lib/std/math | |
| parent | 90989be0e31a91335f8d1c1eafb84c3b34792a8c (diff) | |
| download | zig-ef11bc9899002620d67cfce9c79b6c0dc0f5ea61.tar.gz zig-ef11bc9899002620d67cfce9c79b6c0dc0f5ea61.zip | |
Dwarf: rework self-hosted debug info from scratch
This is in preparation for incremental and actually being able to debug
executables built by the x86_64 backend.
Diffstat (limited to 'lib/std/math')
| -rw-r--r-- | lib/std/math/big/int.zig | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index a7881a8905..f0fd6fca4e 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -2092,6 +2092,12 @@ pub const Const = struct { return bits; } + /// Returns the number of bits required to represent the integer in twos-complement form + /// with the given signedness. + pub fn bitCountTwosCompForSignedness(self: Const, signedness: std.builtin.Signedness) usize { + return self.bitCountTwosComp() + @intFromBool(self.positive and signedness == .signed); + } + /// @popCount with two's complement semantics. /// /// This returns the number of 1 bits set when the value would be represented in @@ -2147,9 +2153,7 @@ pub const Const = struct { if (signedness == .unsigned and !self.positive) { return false; } - - const req_bits = self.bitCountTwosComp() + @intFromBool(self.positive and signedness == .signed); - return bit_count >= req_bits; + return bit_count >= self.bitCountTwosCompForSignedness(signedness); } /// Returns whether self can fit into an integer of the requested type. |
