Optimization with bitwise operators