Best Use & Engineering Application Guide

Engineering Category: Deterministic Sovereign Compute Kernel

Best Use in Production: Pure-Rust C64-bounded integer transformation kernel verified across 64 canonical test vectors for deterministic Snap-Circuit composition.

When to Select This Capsule: Sole canonical implementation for its 64-vector functional equivalence class. Sub-10-cycle hardware kernel (370763/40000 cyc/op); safe for ultra-hot per-sample or per-packet inner loops.

Snap-Circuit Wiring Role: 1-to-1 Unary Transform Stage `(u32)->u32` — snaps directly into linear pipelines or fan-out DAG branches.

Hardware _rdtsc: 370763/40000 cycles/op
Latency: 55183/12500 ns/op
Throughput: 12500000/55183 ops/us
Compiled ELF64 .text: 204 B (61 x86_64 insns)
C64 64KB RAM Budget: 327/65536 (327 B source)
Ternary Vote: + (score 1) | Salience: 2545645/30888
Pure-Rust Capsule Source Code (327 B)
pub fn magic_number_nearest(n: u32) -> u32 {
    let magic = [2, 8, 20, 28, 50, 82, 126, 184];
    let mut best = magic[0];
    let mut best_dist = n.abs_diff(best);
    for &m in &magic[1..] {
        let d = n.abs_diff(m);
        if d < best_dist {
            best_dist = d;
            best = m;
        }
    }
    best
}
rustc -C opt-level=3 x86_64 Disassembly (204 B .text / 61 insns)
magic_number_nearest:
    lea    eax, [rdi - 2]
    mov    ecx, 2
    sub    ecx, edi
    cmovb    ecx, eax
    lea    eax, [rdi - 8]
    mov    edx, 8
    sub    edx, edi
    cmovb    edx, eax
    mov    eax, 2
    cmp    edx, ecx
    cmovae    edx, ecx
    mov    ecx, 8
    cmovae    ecx, eax
    lea    eax, [rdi - 20]
    mov    esi, 20
    sub    esi, edi
    cmovb    esi, eax
    cmp    esi, edx
    cmovae    esi, edx
    mov    eax, 20
    cmovae    eax, ecx
    lea    ecx, [rdi - 28]
    mov    edx, 28
    sub    edx, edi
    cmovb    edx, ecx
    cmp    edx, esi
    cmovae    edx, esi
    mov    ecx, 28
    cmovae    ecx, eax
    lea    eax, [rdi - 50]
    mov    esi, 50
    sub    esi, edi
    cmovb    esi, eax
    cmp    esi, edx
    cmovae    esi, edx
    mov    eax, 50
    cmovae    eax, ecx
    lea    ecx, [rdi - 82]
    mov    edx, 82
    sub    edx, edi
    cmovb    edx, ecx
    cmp    edx, esi
    cmovae    edx, esi
    mov    ecx, 82
    cmovae    ecx, eax
    lea    eax, [rdi - 126]
    mov    esi, 126
    sub    esi, edi
    cmovb    esi, eax
    mov    r8d, 126
    cmp    esi, edx
    cmovae    esi, edx
    cmovae    r8d, ecx
    lea    ecx, [rdi - 184]
    mov    eax, 184
    mov    edx, 184
    sub    edx, edi
    cmovb    edx, ecx
    cmp    edx, esi
    cmovae    eax, r8d
    ret

Head-to-Head Functional Equivalence Class Peers (1 Implementation(s) Matching 64 Test Vectors)

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#937magic_number_nearest (THIS CAPSULE)
domain: Sciforge-x86_64 | id: de8e5369b891001a3d2bd70d20c5f21f
370763/40000 cyc/op55183/12500 ns/op12500000/55183 ops/us204 B .text (61 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz