Repository navigation
Operator Shl Shift Left
Home › Operators › Operator Shl (Shift Left)
Shifts the bits of a numeric expression to the left
Declare Operator Shl ( ByRef lhs As Integer, ByRef rhs As Integer ) As Integer
Declare Operator Shl ( ByRef lhs As UInteger, ByRef rhs As UInteger ) As UInteger
Declare Operator Shl ( ByRef lhs As LongInt, ByRef rhs As LongInt ) As LongInt
Declare Operator Shl ( ByRef lhs As ULongInt, ByRef rhs As ULongInt ) As ULongIntlhsrhs
Operator Shl (Shift left) shifts all of the bits in the left-hand side expression (lhs) left a number of times specified by the right-hand side expression (rhs). Numerically, the result is the same as "CInt( lhs * 2 ^ rhs )". For example, "&b0101 Shl 1" returns the binary number &b01010, and "5 Shl 1" returns 10.
Neither of the operands are modified in any way.
If the result is too large to fit inside the result's data type, the leftmost bits are discarded ("shifted out").
The results of this operation are undefined for values of rhs less than zero, or greater than or equal to the number of bits in the result's data type.
This operator can be overloaded for user-defined types.
Returns the result of lhs being shifted left rhs number of times.
result = lhs Shl rhs
- Not available in the -lang qb dialect unless referenced with the alias
__Shl.
- New to FreeBASIC
'Double a number
For i As Integer = 0 To 10
Print 5 Shl i, Bin(5 Shl i, 16)
Next iOutput:
5 0000000000000101
10 0000000000001010
20 0000000000010100
40 0000000000101000
80 0000000001010000
160 0000000010100000
320 0000000101000000
640 0000001010000000
1280 0000010100000000
2560 0000101000000000
5120 0001010000000000Category: Operators
Kind: operator
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing