Files
bquarkz 3e39a90083
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
feat(vm): add VM-owned PCG64 random and coverage headroom
Implement GC-managed random generators, next/nextf intrinsics, bounded ranges and deterministic conformance coverage. Publish the runtime contract and producer guidance.

Give coverage domains at least five percentage points of measured headroom while preserving sufficient floors. Record local qualification: make ci-domains passes with 939 tests and all domain gates green.
2026-10-09 12:51:05 +01:00

24 lines
1.2 KiB
Python

"""Independent mathematical fixture model (test-only Python arbitrary precision).
Pinned canonical PCG64 seed=42 words cross-check this model; no VM code imported.
"""
from pathlib import Path
from fractions import Fraction
import struct
M = 47026247687942121848144207491837523525
mod = 2**128
rows = ['seed\tdraw\tword_hex\tsigned\tfloat_bits']
first = []
for seed in [0, 1, 42, -1, -(2**63), 2**63-1]:
state = ((seed % 2**64 + 109) * M + 109) % mod
for index in range(1, 9):
state = (state * M + 109) % mod
x = (state % 2**64) ^ (state // 2**64)
rotation = state // 2**122
word = (x // 2**rotation + (x % 2**rotation) * 2**(64-rotation)) % 2**64
signed = word if word < 2**63 else word - 2**64
bits = struct.unpack('>Q', struct.pack('>d', float(Fraction(word // 2**11, 2**53))))[0]
rows.append(f'{seed}\t{index}\t{word:016X}\t{signed}\t{bits:016X}')
if seed == 42 and index <= 6: first.append(f'{word:016X}')
assert first == ['86B1DA1D72062B68','1304AA46C9853D39','A3670E9E0DD50358','F9090E529A7DAE00','C85B9FD837996F2C','606121F8E3919196']
Path(__file__).with_name('random-conformance.tsv').write_text('\n'.join(rows)+'\n')