Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
round.cpp
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#include "round.hpp"
8
9namespace acir_format {
10
11// Rounds a number to the nearest multiple of 8
12uint32_t round_to_nearest_mul_8(uint32_t num_bits)
13{
14 uint32_t remainder = num_bits % 8;
15 if (remainder == 0) {
16 return num_bits;
17 }
18
19 return num_bits + 8 - remainder;
20}
21
22// Rounds the number of bits to the nearest byte
23uint32_t round_to_nearest_byte(uint32_t num_bits)
24{
25 return round_to_nearest_mul_8(num_bits) / 8;
26}
27
28} // namespace acir_format
uint32_t round_to_nearest_mul_8(uint32_t num_bits)
Definition round.cpp:12
uint32_t round_to_nearest_byte(uint32_t num_bits)
Definition round.cpp:23