Bitcoin ABC
0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
src
util
bitmanip.h
Go to the documentation of this file.
1
// Copyright (c) 2019 The Bitcoin developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef BITCOIN_UTIL_BITMANIP_H
6
#define BITCOIN_UTIL_BITMANIP_H
7
8
#include <config/bitcoin-config.h>
9
10
#include <cstdint>
11
12
inline
uint32_t
countBits
(
uint32_t
v) {
13
#if HAVE_DECL___BUILTIN_POPCOUNT
14
return
__builtin_popcount
(v);
15
#else
23
v = v - ((v >> 1) & 0x55555555);
24
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
25
return
(((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
26
#endif
27
}
28
29
#endif
// BITCOIN_UTIL_BITMANIP_H
countBits
uint32_t countBits(uint32_t v)
Definition
bitmanip.h:12
GetRand
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition
random.h:85
Generated on Sat Nov 23 2024 02:38:01 for Bitcoin ABC by
1.9.8