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 (1709533/200000 cyc/op); safe for ultra-hot per-sample or per-packet inner loops.

Snap-Circuit Wiring Role: 2-to-1 Binary Combiner / Join Stage `(i64,i64)->i64` — ideal for merging two upstream DAG branches, dot products, or pairwise rank fusion.

Hardware _rdtsc: 1709533/200000 cycles/op
Latency: 106871/40000 ns/op
Throughput: 40000000/106871 ops/us
Compiled ELF64 .text: 141 B (47 x86_64 insns)
C64 64KB RAM Budget: 211/65536 (211 B source)
Ternary Vote: + (score 1) | Salience: 933835/10296
Pure-Rust Capsule Source Code (211 B)
pub fn round_div_q16(num: i64, den: i64) -> i64 {
    if den == 0 { return 0; }
    let half = den / 2;
    if (num >= 0) == (den > 0) {
        (num + half) / den
    } else {
        (num - half) / den
    }
}
rustc -C opt-level=3 x86_64 Disassembly (141 B .text / 47 insns)
round_div_q16:
    push    rax
    test    rsi, rsi
    je    .LBB7_1
    movabs    rax, -9223372036854775808
    mov    rcx, rsi
    shr    rcx, 63
    add    rcx, rsi
    sar    rcx
    test    rdi, rdi
    setns    dl
    test    rsi, rsi
    setle    r8b
    xor    r8b, dl
    je    .LBB7_8
    mov    rdx, rsi
    not    rdx
    add    rdi, rcx
    xor    rax, rdi
    or    rax, rdx
    jne    .LBB7_3
    lea    rdi, [rip + .Lanon.a270e05f789020653a98a620bea8a67e.5]
    call    qword ptr [rip + _RNvNtNtCscNqnBmBaIcL_4core9panicking11panic_const24panic_const_div_overflow@GOTPCREL]
.LBB7_1:
    xor    eax, eax
    pop    rcx
    ret
.LBB7_8:
    mov    rdx, rsi
    not    rdx
    sub    rdi, rcx
    xor    rax, rdi
    or    rax, rdx
    je    .LBB7_9
.LBB7_3:
    mov    rax, rdi
    or    rax, rsi
    shr    rax, 32
    je    .LBB7_4
    mov    rax, rdi
    cqo
    idiv    rsi
    pop    rcx
    ret
.LBB7_4:
    mov    eax, edi
    xor    edx, edx
    div    esi
    pop    rcx
    ret
.LBB7_9:
    lea    rdi, [rip + .Lanon.a270e05f789020653a98a620bea8a67e.4]
    call    qword ptr [rip + _RNvNtNtCscNqnBmBaIcL_4core9panicking11panic_const24panic_const_div_overflow@GOTPCREL]

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

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#202round_div_q16 (THIS CAPSULE)
domain: math | id: 24190df2f99d90771ffcd00281129dee
1709533/200000 cyc/op106871/40000 ns/op40000000/106871 ops/us141 B .text (47 insns)+ (1)aye::Peter+Omni(0+1)::aarch64 @ 432Hz