Worked example
Operation: Decimal → bits a: -1 Bit width: 8
→ 1111 1111; hex: FF; 10: −1
Method and scope
Encode a signed decimal integer or decode an exact-width binary string (without spaces). The leading bit is the sign bit. Range: −2^(w−1) to 2^(w−1)−1. Out-of-range values are rejected, never silently wrapped.
negative x → 2ʷ + x
Precision and limits
≈ marks an approximation. Display rounding does not change the internal calculation.