Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / u64.h / msb64.3.md

% limb manual
% msb64(3)
% limb 0.1.0
% 2023-07-24

# NAME

msb64 - return the position of the most significant bit set

# SYNOPSIS

    #include <limb/uint64.h>

```pre hl
int msb64(u64 <em>val</em>)
```

# DESCRIPTION

The `msb64`() function returns the position of the last (most significant) bit
set in `val`.

The least significant bit is position 1 and the most significant bit is
position 64.

# RETURN VALUE

`msb64`() returns the position of the most significant bit set (from 1 to 64),
or 0 if no bits are set (i.e. `val` is zero).