Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
bitoperations.h
Go to the documentation of this file.
1#pragma once
2#include <cstdint>
3
5
9inline uint64_t smallestIntWithNBitsSet(uint64_t n) {
10 STORM_LOG_ASSERT(n < 64, "Input is too large.");
11 if (n == 0)
12 return 0;
13 return (1ul << n) - 1;
14}
15
24inline uint64_t nextBitPermutation(uint64_t v) {
25 if (v == 0)
26 return 0;
27 uint64_t t = (v | (v - 1)) + 1;
28 return t | ((((t & -t) / (v & -v)) >> 1) - 1);
29}
uint64_t nextBitPermutation(uint64_t v)
The next bit permutation in a lexicographical sense.
uint64_t smallestIntWithNBitsSet(uint64_t n)
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11