MMgr v1.0.0
Zero-heap memory manager in C11. One borrowed buffer, carved by asserted offset.
Loading...
Searching...
No Matches
pow5.h File Reference

Powers of five as 128-bit significands, for scaling a decimal mantissa into a binary one. More...

#include "mmgr.h"

Go to the source code of this file.

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 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 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

Powers of five as 128-bit significands, for scaling a decimal mantissa into a binary one.

Author
dstroy0 (Douglas Quigg) dquig.nosp@m.g123.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Date
2026-08-29
Note
transformo walks the bits of the decimal exponent and multiplies in one entry per set bit, and so nine entries reach 511.
Declares no function. Both tables are static const data that outlive every call. A pointer into one stays good for the whole program [BORROWS].

Definition in file pow5.h.

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 32 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 an exponent is carried in wherever the two are compared.
Warning
muto_scale bounds against this and returns infinity above it and zero below its negative; muto_scale_to_u64 does not. What keeps 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 44 of file pow5.h.

Variable Documentation

◆ mmgr_pow5_up

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, and 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 are truncated toward zero and read a little low.
Every significand literal carries ULL to match the embed_u64 it is stored in. 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 keeps a unit that never reads it quiet, and an entry's address stays good for the whole program [BORROWS].
Warning
transformo settles a positive exponent from its exact powers of ten and returns before the walk, and the only exponent reaching this table there is zero, which sets no bit.

Definition at line 72 of file pow5.h.

◆ mmgr_pow5_down

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: 5^-1 is the repeating 0xCCCC..., not the 0xCCCD... that rounding to nearest would give.
Every significand literal carries ULL to match the embed_u64 it is stored in. 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 keeps a unit that never reads it quiet, and an entry's address stays good for the whole program [BORROWS].

Definition at line 93 of file pow5.h.