Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/utils/libbit.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ function popCount(uint256 x) internal pure returns (uint256 c)

Returns the number of set bits in `x`.

### countZeroBytes(uint256)

```solidity
function countZeroBytes(uint256 x) internal pure returns (uint256 c)
```

Returns the number of zero bytes in `x`.
To get the number of non-zero bytes, simply do `32 - countZeroBytes(x)`.

### isPo2(uint256)

```solidity
Expand Down
4 changes: 2 additions & 2 deletions src/utils/LibBit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ library LibBit {
}
}

/// @dev Returns the number of zero bits in `x`.
/// To get the number of non-zero bytes, simply do `32 - countZeroBytes(x)`
/// @dev Returns the number of zero bytes in `x`.
/// To get the number of non-zero bytes, simply do `32 - countZeroBytes(x)`.
function countZeroBytes(uint256 x) internal pure returns (uint256 c) {
/// @solidity memory-safe-assembly
assembly {
Expand Down