Skip to main content

Module arithmetic

Module arithmetic 

Source
Expand description

Re-export the core rANS primitives. Arithmetic primitives for rANS.

This module provides:

  • mul_hi_u64: High 64 bits of 64x64 multiply (equivalent to __umulh / Mul64Hi)
  • compute_reciprocal: Reciprocal frequency preparation for fast division

The arithmetic here must match the Microsoft C++ implementation exactly.

Functionsยง

compute_reciprocal_u32
Compute the fixed-point reciprocal frequency for a 32-bit state.
compute_reciprocal_u64
Compute the fixed-point reciprocal frequency for a 64-bit state.
fast_quotient_u32
fast_quotient_u64
Perform fast division by frequency using the reciprocal.
freq_one_reciprocal_u32
Compute the frequency-one reciprocal for 32-bit state.
freq_one_reciprocal_u64
Compute the frequency-one reciprocal for 64-bit state.
mul_hi_u64
Returns the high 64 bits of the 128-bit product of two 64-bit integers.
reciprocal_shift
Compute the reciprocal shift for a given frequency.