Code location: SUBSECTION 15.2 in flowlog.c.
Flowlog uses a two-tier integer model:
pl_term as SLO
(PL_TERM_INT).pl_bigint
(PL_TERM_BIGINT) when values do not fit in
SLO.struct pl_bigint {
int sign; // -1, 0, +1
ULO len; // number of limbs
uint32_t limbs[len]; // little-endian base-2^32 limbs
}
Notes: - Limbs are little-endian (limbs[0] is the
least-significant 32 bits). - The base is 2^32, so each
limb stores 32 bits. - Bigints are normalized: no
leading zero limbs; zero is represented as
sign=0, len=0.
SLO uses overflow checks; on overflow,
operands are promoted to pl_bigint.pl_bigint fits in SLO, it is demoted back to
PL_TERM_INT.current_prolog_flag(bounded,false) true
while preserving fast paths for small integers.+, -, *:
SLO fast paths with overflow detection.* uses schoolbook multiplication for small limb
counts and Karatsuba for larger operands.^ (power) uses exponentiation by squaring, with a
specialized bigint squaring fast path (switches to Karatsuba at large
sizes).// and rem use truncation toward
zero.div and mod use floor
division (ISO behavior).<< shifts left by inserting zero bits.>> shifts right using floor
semantics for negative values (consistent with div by
powers of two)./\\, \\/, xor,
\\) operate on a fixed-width two’s-complement view:
max(bit_length(|A|), bit_length(|B|)) + 1number_chars/2 and number_codes/2 parse
decimal digits into SLO or pl_bigint as
needed.num_as_double) attempts
exact conversion; very large values map to ±HUGE_VAL.double.