larzbits
Bitwise operations made visible.
Bit manipulation is where many learners hit a wall - the operators are terse and the effect invisible. larzbits does the operation and shows it lined up in binary, so 12 AND 10 = 8 becomes an obvious column-by-column picture. Pairs with larzbase.
larzscript pkg install bits
What you get
- AND/OR/XOR/NOT and shifts
- to_bits() with two's complement
- explain() lines it up in binary
- Finally see what bits do
Try it
import "bits" as bits print(bits.b_and(12, 10)) print(bits.b_or(12, 10)) print(bits.b_xor(12, 10)) print(bits.shift_left(1, 4)) print(bits.to_bits(-5, 8))
Output
8 14 6 16 11111011
Why it's in the Larz Stack
larzbits is a real Larzscript package (larzscript pkg install bits) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.