Skip to content

Commit

Permalink
Clarify doc comments for half_mod_odd
Browse files Browse the repository at this point in the history
  • Loading branch information
chiphogg committed Nov 8, 2024
1 parent e392e09 commit b6369a3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions au/code/au/utility/mod.hh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ constexpr uint64_t mul_mod(uint64_t a, uint64_t b, uint64_t n) {
//
// Precondition: (a < n).
// Precondition: (n is odd).
//
// If `a` is even, this is of course simply `a / 2` (because `(a < n)` as a precondition).
// Otherwise, we give the result one would obtain by first adding `n` (guaranteeing an even number,
// since `n` is also odd as a precondition), and _then_ dividing by `2`.
constexpr uint64_t half_mod_odd(uint64_t a, uint64_t n) {
return (a / 2u) + ((a % 2u == 0u) ? 0u : (n / 2u + 1u));
}
Expand Down

0 comments on commit b6369a3

Please sign in to comment.