RosettaCodeData/Task/Bitwise-operations/RLaB/bitwise-operations.rlab

14 lines
475 B
Plaintext

>> x = int(3);
>> y = int(1);
>> z = x && y; printf("0x%08x\n",z); // logical 'and'
0x00000001
>> z = x || y; printf("0x%08x\n",z); // logical 'or'
0x00000003
>> z = !x; printf("0x%08x\n",z); // logical 'not'
0xfffffffc
>> i2 = int(2);
>> z = x * i2; printf("0x%08x\n",z); // left-shift is multiplication by 2 where both arguments are integers
0x00000006
>> z = x / i2; printf("0x%08x\n",z); // right-shift is division by 2 where both arguments are integers
0x00000001