---
name: "bitmap_pos_to_ord"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/bitmap_pos_to_ord"
---

# bitmap\_pos\_to\_ord(9)

find ordinal of set bit at given position in bitmap

## NAME

bitmap\_pos\_to\_ord - find ordinal of set bit at given position in bitmap

## SYNOPSIS

**int bitmap\_pos\_to\_ord(const unsigned long \*** *buf***, unsigned int** *pos***, unsigned int** *nbits***);**

## ARGUMENTS

*buf*

pointer to a bitmap

*pos*

a bit position in *buf* (0 \<= *pos* \< *nbits*)

*nbits*

number of valid bit positions in *buf*

## DESCRIPTION

Map the bit at position *pos* in *buf* (of length *nbits*) to the ordinal of which set bit it is. If it is not set or if *pos* is not a valid bit position, map to -1.

If for example, just bits 4 through 7 are set in *buf*, then *pos* values 4 through 7 will get mapped to 0 through 3, respectively, and other *pos* values will get mapped to -1. When *pos* value 7 gets mapped to (returns) *ord* value 3 in this example, that means that bit 7 is the 3rd (starting with 0th) set bit in *buf*.

The bit positions 0 through *bits* are valid positions in *buf*.

## COPYRIGHT
