7 | | Because 0xf0 before the shift is useless. Applying the 0x0f after moving ensures that for v > 255 or < 0 it does not throw exception. If it is sure, that always v >= 0 && v <= 255, then {{{[v >> 4]}}} is all you need. |
| 7 | Applying the 0x0f after moving ensures that for v > 255 or < 0 it does not throw exception. If it is sure, that always v >= 0 && v <= 255, then {{{[v >> 4]}}} is all you need. |
| 8 | |
| 9 | You're right, that result for int is equal, as &0xf0 effectively also kills any sign. Thought from programming experience I know the array access security check should always be the outermost operation :-) |