2 ms·
The usual reason is packing/unpacking bitfields. To extract the hours/minutes/seconds from a DOS timestamp hour = (timestamp >> 11) & 0x1f min = (timestam
by edflsafoiewq 5y ago
The usual reason is packing/unpacking bitfields.
To extract the hours/minutes/seconds from a DOS timestamp
hour = (timestamp >> 11) & 0x1f
min = (timestamp >> 5) & 0x3f
sec = (timestamp & 0x1f) * 2
To check if a byte is a UTF-8 continuation byte
(x >> 6) == 0b10
To pack 5-bit r, g, b values into a 16-bit integer
(uint16)r | ((uint16)g << 5) | ((uint16)b << 10)
To swap the bytes of a uint32 (little endian <-> big endian conversion)
(x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24)