Shifts a number to the left by a specified amount of bits and returns the result found after the shift.
BITLSHIFT(number, shift_amount)
number should be 0 or higher.
shift_amount is an integer.
Example:
If number contains 1 and shift_amount contains 2:
BITLSHIFT(1, 2)
returns 4
numberOne:
numberTwo:
Result:
Fast Scoring in a Game
Imagine you are developing a simple arcade game where a player's score can increase based on different actions. Let's say a player gets points for collecting items. To make the scoring dynamic and fast, you decide to use a bit shift operation.
Instead of doing a slow multiplication (score * 2), you can use a bitwise left shift to quickly double the score.
Here is a table demonstrating how this works:
Action | Current Score (Decimal) | Current Score (Binary) | Power-Up Multiplier | BITLSHIFT Operation | New Score (Decimal) | New Score (Binary) | ||
|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | ||
1 | Start | 0 | 0000 | 0 | - | 0 | 0000 | |
2 | Collect Item 1 | 1 | 0001 | 0 | - | 1 | 0001 | |
3 | Collect Item 2 | 2 | 0010 | 0 | - | 2 | 0010 | |
4 | Collect Power-Up | 2 | 0010 | 1 | - | 2 | 0010 | |
5 | Collect Item 3 (with Power-Up) | 2 | 0010 | 1 | BITLSHIFT(2, 1) | 4 | 0100 | |
6 | Collect Item 4 (with Power-Up) | 4 | 0100 | 1 | BITLSHIFT(4, 1) | 8 | 1000 | |
7 | Collect Item 5 (Power-Up fades) | 8 | 1000 | 0 | - | 9 | 1001 |
Explanation:
This example illustrates how BITLSHIFT can be a very efficient way to multiply by powers of two, which is a common requirement in many programming tasks where performance is critical.
PRODUCT & FEATURES
RESOURCES
Terms | Privacy | Spam Policy
© 2026 Zapof