Skip to content

Bitwise Operations

Bitwise Operations - a subtle tool for operating bits in a number.

Supported

Supported Types For Bitwise Operations: int8 / int16 / int32 / int64

SignNameDescription
&ANDCopies a bit to the result if it exists in both operands
|ORCopies a bit if it exists in either operand
^XORCopies the bit if it set in one operand but not both
<<LEFT SHIFTShifts bits to left by provided number
>>RIGHT SHIFTShifts bits to right by provided number

Examples

tpl-lang
print(5 & 1);
print(2 | 4);
print(3 ^ 1);
print(1 << 2);
print(10 >> 2);

1
6
2
4
2