data-structures-c
Loading...
Searching...
No Matches
lib
is_pow2.h
Go to the documentation of this file.
1
/* is_pow2.h
2
*
3
* Copyright (C) 2023 abxh
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
9
* See the file LICENSE included with this distribution for more
10
* information. */
11
17
#pragma once
18
19
#include <stdlib.h>
20
25
#define IS_POW2(X) ((X) != 0 && ((X) & ((X) - 1)) == 0)
26
34
static
inline
size_t
is_pow2
(
const
size_t
x)
35
{
36
return
x != 0 && (x & (x - 1)) == 0;
37
}
38
39
// vim: ft=c
is_pow2
static size_t is_pow2(const size_t x)
Check if a number is a power of two.
Definition
is_pow2.h:34
Generated by
1.12.0