MySQL 8.4.2
Source Code Documentation
|
Allows to execute x % mod for a specified mod in a fast way, without using a slow operation of division. More...
#include <ut0math.h>
Public Member Functions | |
fast_modulo_t ()=default | |
fast_modulo_t (uint64_t mod) | |
fast_modulo_t (uint64_t mod, uint64_t inv) | |
uint64_t | compute (uint64_t x) const |
Computes the value of x % mod. More... | |
uint64_t | get_inverse () const |
Gets the precomputed value of inverse. More... | |
uint64_t | get_mod () const |
Gets the modulo value. More... | |
Static Public Member Functions | |
static uint64_t | precompute_inv (uint64_t mod) |
Precomputes the inverse needed for fast modulo operations. More... | |
Private Attributes | |
uint64_t | m_mod {0} |
uint64_t | m_inv {0} |
Allows to execute x % mod for a specified mod in a fast way, without using a slow operation of division.
The additional cost is hidden in constructor to preprocess the mod constant.
|
default |
|
inlineexplicit |
|
inlineexplicit |
|
inline |
Computes the value of x % mod.
|
inline |
Gets the precomputed value of inverse.
|
inline |
Gets the modulo value.
|
inlinestatic |
Precomputes the inverse needed for fast modulo operations.
|
private |
|
private |