SDL Wiki


Use this function to get the index of the most significant (set) bit in a 32-bit number. This is also the same as the base 2 logarithm of the number.


int SDL_MostSignificantBitIndex32(Uint32 x)

Function Parameters


the number to find the MSB of

Return Value

Returns the index of the most significant bit of x, or -1 if x is 0.

Code Examples

#include "SDL_bits.h"

if (bitmask) {
    int index = SDL_MostSignificantBitIndex32(bitmask);

CategoryAPI, CategoryBits

[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.