xHarbour Reference Documentation > Operator Reference |
Left-shift operator (binary): shifts bits to the left.
<nNumber1> << <nNumber2>
The << operator accesses individual bits in the left operand and shifts them to the left as many times as specified with the right operand. Both operands are always treated as integer values. If an operand has a decimal fraction, it is truncated prior to the operation.
A shift operation involves all bits of the left operand. When the bits are shifted one place to the left, the highest bit is discarded and the lowest bit is set to 0. A numeric value has 32 bits on a 32 bit operating system.
Shifting a value to the left is equivalent with multiplying <nNumber1> by 2 raised to the power of <nNumber2>.
See also: | >>, HB_BitShift() |
Category: | Bitwise operators , Operators , xHarbour extensions |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// This example shifts the bits of the value 52 two places to // the left so the value becomes 208. PROCEDURE Main nValue := 52 // binary: 00110100 ? nValue << 2 // binary: 11010000 (value = 208) ? 52 * 2 ˆ 2 // result: 208 RETURN
http://www.xHarbour.com