data-structures-c
Loading...
Searching...
No Matches
round_up_pow2.h File Reference

Round up to the next power of two. More...

#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Functions

static uint32_t round_up_pow2_32 (uint32_t x)
 

Detailed Description

Function Documentation

◆ round_up_pow2_32()

static uint32_t round_up_pow2_32 ( uint32_t x)
inlinestatic

Round up to the next power of two.

Assumes:

  • x is strictly larger than 0.
  • x is smaller than than or equal to UINT32_MAX / 2 + 1.
Parameters
xThe number at hand.
Returns
A power of two that is larger than or equal to the given number.