Bitcoin ABC 0.30.7
P2P Digital Currency
Functions
fastrange.h File Reference
#include <cstdint>
Include dependency graph for fastrange.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static uint32_t FastRange32 (uint32_t x, uint32_t n)
 This file offers implementations of the fast range reduction technique described in https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/. More...
 
static uint64_t FastRange64 (uint64_t x, uint64_t n)
 Fast range reduction with 64-bit input and 64-bit range. More...
 

Function Documentation

◆ FastRange32()

static uint32_t FastRange32 ( uint32_t  x,
uint32_t  n 
)
inlinestatic

This file offers implementations of the fast range reduction technique described in https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/.

In short, they take an integer x and a range n, and return the upper bits of (x * n). If x is uniformly distributed over its domain, the result is as close to uniformly distributed over [0, n) as (x mod n) would be, but significantly faster. Fast range reduction with 32-bit input and 32-bit range.

Definition at line 22 of file fastrange.h.

Here is the caller graph for this function:

◆ FastRange64()

static uint64_t FastRange64 ( uint64_t  x,
uint64_t  n 
)
inlinestatic

Fast range reduction with 64-bit input and 64-bit range.

Definition at line 27 of file fastrange.h.

Here is the caller graph for this function: