Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
keep_n_lsb.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
8#include <cstddef>
9
10namespace bb::numeric {
11
12template <typename T> inline T keep_n_lsb(T const& input, size_t num_bits)
13{
14 return num_bits >= sizeof(T) * 8 ? input : input & ((T(1) << num_bits) - 1);
15}
16
17} // namespace bb::numeric
T keep_n_lsb(T const &input, size_t num_bits)