Sign in Join
FPDoc Onlineexperiment

BsrWord function

In unit System

Return the position of the leftmost set bit in a 16-bit value.

Declaration

pascal
function BsrWord(const AValue: Word): Cardinal

Description

BsrWord scans the word AValue, starting at the leftmost position and working towards position 0, and returns the index of the first set bit. The position is measured from the 0-th, rightmost bit.

When the input is 0, the result is 255 (unsigned equivalent of -1).

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.