Changes between Version 1 and Version 2 of Ticket #8902, comment 29


Ignore:
Timestamp:
2013-07-31T08:45:53+02:00 (12 years ago)
Author:
stoecker

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #8902, comment 29

    v1 v2  
    55> Why? V is int so result is same. I choose this because mask and move looks more illustrative for me.
    66
    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.
     7Applying 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
     9You'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 :-)