MMgr v2.3.0
Zero-heap memory manager in C11. One borrowed buffer, carved by asserted offset.
Loading...
Searching...
No Matches
pow5 — powers of five

Data Structures

struct  MmgrPow5
 One power of five, as a 128-bit significand with a binary exponent. More...

Macros

#define MMGR_POW5_STEPS
 Expands to 9, the number of entries in each table.
#define MMGR_POW5_MAX
 Expands to ((1 << 9) - 1), which is 511, the largest decimal exponent the tables reach.

Variables

static EMBED_PASS_MEMORY const MmgrPow5 mmgr_pow5_up [MMGR_POW5_STEPS]
 Five raised to each power of two, from 5^1 at index 0 to 5^256 at index 8.
static EMBED_PASS_MEMORY const MmgrPow5 mmgr_pow5_down [MMGR_POW5_STEPS]
 The reciprocal of each mmgr_pow5_up entry, from 5^-1 at index 0 to 5^-256 at index 8.

Detailed Description

Macro Definition Documentation

◆ MMGR_POW5_STEPS

#define MMGR_POW5_STEPS

Expands to 9, the number of entries in each table.

Note
Entry i holds five raised to two to the i, and so the nine entries run from 5^1 to 5^256.
Carries no suffix: it sizes both tables and bounds the walk, where it converts to the signed embed_iword the loop counts in.

Definition at line 35 of file pow5.h.

◆ MMGR_POW5_MAX

#define MMGR_POW5_MAX

Expands to ((1 << 9) - 1), which is 511, the largest decimal exponent the tables reach.

Note
Every one of the nine entries multiplied together gives 5^511.
The expansion is a plain int constant expression, which widens to the embed_iword that carries an exponent wherever the two compare.
Warning
muto_scale bounds against this and returns infinity above it and zero below its negative; muto_scale_to_u64 does not. What retains either off the end of the tables is the walk itself, which takes only MMGR_POW5_STEPS steps. An exponent past this loses its higher bits.

Definition at line 47 of file pow5.h.

Variable Documentation

◆ mmgr_pow5_up

EMBED_PASS_MEMORY const MmgrPow5 mmgr_pow5_up[MMGR_POW5_STEPS]
static

Five raised to each power of two, from 5^1 at index 0 to 5^256 at index 8.

Note
Entry i is the multiplier for bit i of the exponent magnitude. The walk in muto_apply_pow10 takes this table over mmgr_pow5_down whenever the decimal exponent is not negative.
Index 0 through 5 are exact. 5^64 and up need more than 128 bits, and so the last three entries come truncated toward zero and read a little low.
Every significand literal carries ULL to match the embed_u64 that holds it. Each e2 is a bare int that converts to embed_iword.
static const at header scope, and each translation unit gets its own copy. EMBED_UNUSED retains a unit that never reads it quiet, and an entry's address stays good for the whole program [BORROWS].
EMBED_PASS_MEMORY gives each pass of nvcc its own copy, and so a kernel reads the table from device memory.
Warning
transformo settles a positive exponent from its exact powers of ten and returns before the walk. The only exponent that reaches this table there is zero, which sets no bit.

Definition at line 76 of file pow5.h.

◆ mmgr_pow5_down

EMBED_PASS_MEMORY const MmgrPow5 mmgr_pow5_down[MMGR_POW5_STEPS]
static

The reciprocal of each mmgr_pow5_up entry, from 5^-1 at index 0 to 5^-256 at index 8.

Note
Entry i is the multiplier for bit i of the exponent magnitude, and the walk in muto_apply_pow10 takes this table when the decimal exponent is negative.
No negative power of five ends in binary. All nine are the exact value truncated toward zero. Every entry reads a little low and none of them round up. The entry for 5^-1 is 0xCCCC... with the C repeated, not the 0xCCCD... that a round to nearest would give.
Every significand literal carries ULL to match the embed_u64 that holds it. Each e2 is a bare int that converts to embed_iword.
static const at header scope, and each translation unit gets its own copy. EMBED_UNUSED retains a unit that never reads it quiet, and an entry's address stays good for the whole program [BORROWS].
EMBED_PASS_MEMORY gives each pass of nvcc its own copy, as it does mmgr_pow5_up.

Definition at line 98 of file pow5.h.