MCPcopy Create free account
hub / github.com/ElementsProject/elements / getBit

Function getBit

src/simplicity/bitstring.h:31–35  ·  view source on GitHub ↗

Return the nth bit from a bitstring. * * Precondition: NULL != s * n < s->len; */

Source from the content-addressed store, hash-verified

29 * n < s->len;
30 */
31static inline bool getBit(const bitstring *s, size_t n) {
32 size_t total_offset = s->offset + n;
33 simplicity_assert(n < s->len);
34 return 1 & (s->arr[total_offset / CHAR_BIT] >> (CHAR_BIT - 1 - (total_offset % CHAR_BIT)));
35}
36
37/* Return 8 bits from a bitstring staring from the nth bit.
38 *

Callers 2

writeValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected