0 Members and 1 Guest are viewing this topic.
Multiplication by 2^n is the same as bit shifting to the left (<<) by n.Division by 2^n is the same as bit shifting to the right (>>) by n.The ACS right-shift is what is called an "arithmetic shift", i.e. it preserves the sign.
ACS, Signed Integers, and BitShifts:Test 0: 32Int Value: 32Binary Value: 3 2 1 01098765432109876543210987654321000000000000000000000000000100000Test 1: 32 >> 2Int Value: 8Binary Value: 3 2 1 01098765432109876543210987654321000000000000000000000000000001000Test 2: 32 << 2Int Value: 128Binary Value: 3 2 1 01098765432109876543210987654321000000000000000000000000010000000Test 3: -32Int Value: -32Binary Value: 3 2 1 01098765432109876543210987654321011111111111111111111111111100000Test 4: -32 >> 2Int Value: -8Binary Value: 3 2 1 01098765432109876543210987654321011111111111111111111111111111000Test 5: -32 << 2Int Value: -128Binary Value: 3 2 1 01098765432109876543210987654321011111111111111111111111110000000