Binary in JavaScript
summary
Concrete savings and concrete techniques: a 512×512 game reduces memory from 16MB to 4MB by packing tile fields into a single integer, using bitwise masks and shifts. JavaScript numbers are IEEE floats but bitwise operators coerce to 32‑bit integers and truncate decimals; & and | mask bits, ~ flips all bits, << doubles, >> preserves sign, >>> zero‑fills. Also shows the XOR swap without a third variable and warns against clever hacks like >>>0 for parseInt in production.
AI-written summary · about








