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

Check if a number is a power of two. More...

#include <stdlib.h>

Go to the source code of this file.

Macros

#define IS_POW2(X)
 compile time is_pow2.
 

Functions

static size_t is_pow2 (const size_t x)
 Check if a number is a power of two.
 

Detailed Description

Check if a number is a power of two.

Macro Definition Documentation

◆ IS_POW2

#define IS_POW2 ( X)
Value:
((X) != 0 && ((X) & ((X) - 1)) == 0)

compile time is_pow2.

Function Documentation

◆ is_pow2()

static size_t is_pow2 ( const size_t x)
inlinestatic

Check if a number is a power of two.

Parameters
[in]xThe number at hand.
Returns
A boolean value indicating whether the number is a power of two.