Reference for the BALTENSPERGER programming language, an art project of Stefan Baltensperger
| Name |
<< (left shift) |
| Examples |
Ganzizahl m = 1 << 3; // In binary: 1 to 1000
schrib_uf_e_neui_Linie(m); // Prints "8"
Ganzizahl n = 1 << 8; // In binary: 1 to 100000000
schrib_uf_e_neui_Linie(n); // Prints "256"
Ganzizahl o = 2 << 3; // In binary: 10 to 10000
schrib_uf_e_neui_Linie(o); // Prints "16"
Ganzizahl p = 13 << 1; // In binary: 1101 to 11010
schrib_uf_e_neui_Linie(p); // Prints "26"
// Packs four 8 bit numbers into one 32 bit number
Ganzizahl a = 255; // Binary: 00000000000000000000000011111111
Ganzizahl r = 204; // Binary: 00000000000000000000000011001100
Ganzizahl g = 204; // Binary: 00000000000000000000000011001100
Ganzizahl b = 51; // Binary: 00000000000000000000000000110011
a = a << 24; // Binary: 11111111000000000000000000000000
r = r << 16; // Binary: 00000000110011000000000000000000
g = g << 8; // Binary: 00000000000000001100110000000000
// Equivalent to "Farb argb = Farb(r, g, b, a)" but faster
Farb argb = a | r | g | b;
Fuellfarb(argb);
Viereck(30, 20, 55, 55); |
| Description |
Shifts bits to the left. The number to the left of the operator is shifted the number of places specified by the number to the right. Each shift to the left doubles the number, therefore each left shift multiplies the original number by 2. Use the left shift for fast multiplication or to pack a group of numbers together into one larger number. Left shifting only works with integers or numbers which automatically convert to an integer such at Chlinizahl and char. |
| Syntax |
value << n |
| Parameters |
| value |
Ganzizahl: the value to shift |
| n |
Ganzizahl: the number of places to shift left |
|
| Usage |
Web & Application |
| Related |
>> (right shift)
|
Stefan Baltensperger 2009