Code: Select all
X = 1 << 63
Y = X >> 1
Debug Hex(Y)
C0000000 00000000.
Code: Select all
X = 1 << 63
Y = X >> 1
Debug Hex(Y)
As there is only a difference in the right shift I would not use >>> as logic shift, since one would expect a <<< then for the sake of symmetry.wilbert wrote:I requested it also before.
Both java and javascript have >> operator for arithmetic shift (like PB) and >>> for logical shift.
Code: Select all
change32(n, 5)
Code: Select all
<^ ^>
<< >>
^< >^
<<< >>>
Code: Select all
Procedure ToggleBit32(value, bit)
!xor eax, eax
!mov ecx, dword [p.v_bit]
!bts eax, ecx
!mov ecx, dword [p.v_value]
!xor eax, ecx
ProcedureReturn
EndProcedure
Procedure.q ToggleBit64(value.q, bit.q)
CompilerIf #PB_Compiler_Processor=#PB_Processor_x64
!xor rax, rax
!mov rcx, qword [p.v_bit]
!bts rax, rcx
!mov rcx, qword [p.v_value]
!xor rax, rcx
ProcedureReturn
CompilerElse
ProcedureReturn (1 << bit) ! value
CompilerEndIf
ProcedureReturn
EndProcedure
a = %11011
c = ToggleBit32(a, 31)
Debug Bin(c, #PB_Long)