logical shift
Posted: Wed Jan 16, 2013 10:16 am
At this point, in PureBasic, there is only an arithmetic shift, but would not hurt to add and logical shift. The situation is complicated by the fact that there is no unsigned variables.
The example shows that the arithmetic shift results in an error.Logical shift gives the correct result even with a signed variable.
The example shows that the arithmetic shift results in an error.
Code: Select all
x=-1
x>>4
Debug x
Debug RSet(Hex(x, #PB_Long), 8, "0")
Code: Select all
EnableASM
x=-1
mov eax, x
shr eax, 4
mov x, eax
Debug x
Debug RSet(Hex(x, #PB_Long), 8, "0")