Python Truthiness and Equivalence Classes: A Mathematical Perspective
Introduction Recently, I ran into a bug in Rust while I was checking if bits were set in a u64. fn is_bit_set(n: u64, k: usize) -> bool { n & (1 << k) == 1 } Let’s run it on some input and see what happens. fn is_bit_set(n: u64, k: usize) -> bool { (n & (1 << k)) == 1 } fn main() { let n = 51; for k in 0....