3 ms·
0x80 is 0b01010000. Consider that (foo & 0x80) is (0x16 == 0b00010000) if foo is 0x16. (This may or may not be the intended functionality one way or the other
by Hytosys 13y ago
0x80 is 0b01010000.
Consider that (foo & 0x80) is (0x16 == 0b00010000) if foo is 0x16.
(This may or may not be the intended functionality one way or the other!)
- RegEx 13y agoI believe 0x80 is 0b1000000
- Hytosys 13y agoOops, did everything in decimal. Good point and correction. Still, the difference in legibility and implications of the two lines of code are important. Modern compilers would optimize ((foo & 0x80) == 0x80) to (foo & 0x80) but leave ((foo & 0x60) == 0x60) alone because it is testing more than one bit.