Best Use & Engineering Application Guide

Engineering Category: Lossless Wire & Structural Compression

Best Use in Production: Zero-allocation integer bit-packing, variable-length encoding, and stream framing for sovereign wire protocols.

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

Snap-Circuit Wiring Role: Specialized Multi-Pin Stage `(u8,u8)->u8` — wire matching input pins via `snap_dag` or `snap_pipeline`.

Hardware _rdtsc: 403129/100000 cycles/op
Latency: 384093/200000 ns/op
Throughput: 200000000/384093 ops/us
Compiled ELF64 .text: 15 B (6 x86_64 insns)
C64 64KB RAM Budget: 43/32768 (86 B source)
Ternary Vote: + (score 1) | Salience: 283/3
Pure-Rust Capsule Source Code (86 B)
pub fn avg2(a: u8, b: u8) -> u8 {
    ((u16::from(a) + u16::from(b) + 1) >> 1) as u8
}
rustc -C opt-level=3 x86_64 Disassembly (15 B .text / 6 insns)
avg2:
    movzx    eax, sil
    movzx    ecx, dil
    add    eax, ecx
    inc    eax
    shr    eax
    ret

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

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#48avg2 (THIS CAPSULE)
domain: smart-tree | id: 044a535449e0cf6f8429be5d1ce2ca94
403129/100000 cyc/op384093/200000 ns/op200000000/384093 ops/us15 B .text (6 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz