Equinox Online Help - Language Reference - A to Z

Home

ShiftLeft

Applies to
SyntaxShiftLeft(Item[,NumberOfShifts])
ActionShift Item left NumberOf Shift times. Item is ulong. Bits at the high order end of the number are lost, and zero bits are added at the low order end. Practically speaking Number of shifts can be in the range -31 to +31 and default to +1. Negative values cause right shifts in a similar way.
Scope
Notes

This command allows bit manipulation of 32 bit values. Additionally overflow checking in arithmatic using ulong numbers has been relaxed as overflow is a common technique for truncating high order bits. Note also that Equinox treats the AND and OR operators as binary operators while they are inside brackets.

CategoryMaths
See Also RotateLeft
Example

This example prints the number 42

print ShiftLeft(21)

This example prints the number 1

print ShiftLeft(0X800000000,-31)

This example encodes two numbers using the XTEA encryption scheme. The encryption key is supplied in an array of 4 ulongs

procedure XTEA ulong y, ulongz, ulong uKey[]
ulong sum
int i

sum=0

for i = 1 to 32
y+=(ShiftLeft(z,4) xor ShiftLeft(z,-5))+ z xor sum + uKey[(sum and 3)+1]
sum+=0X9E3779B9
z+=(ShiftLeft(y,4) xor ShiftLeft(y,-5))+y xor sum +uKey[(ShiftLeft(sum,-11)and 3) +1]
next
end procedure | XTEA

This example decodes two numbers using the XTEA encryption system

Procedure AETX ulong y, ulong z, ulong uKey[]
ulong sum
int i

sum = 0xC6EF3720

for i = 1 to 32
z-=(ShiftLeft(y,4) xor ShiftLeft(y,-5)) + y xor sum + uKey[(ShiftLeft(sum,-11)and 3)+1]
sum -=0x9E3779B9
y-=(ShiftLeft(z,4) xor ShiftLeft(z,-5)) +z xor sum + uKey[(sum and 3) + !]
next
end procedure | AETX