Bitwise Operations and Numbers
Bitwise operations
| Syntax | Meaning |
|---|---|
a ⭕ b |
bitwise AND |
a 💢 b |
bitwise OR |
a ❌ b |
bitwise XOR |
a 👈 n |
shift left by n bits |
a 👉 n |
shift right by n bits |
❎ a❗️ |
invert the bits (NOT) |
🏁 🍇
12 ➡️ a 💭 1100 in binary
10 ➡️ b 💭 1010 in binary
😀 🔡 a ⭕ b 2❗️❗️
😀 🔡 a 💢 b 2❗️❗️
😀 🔡 a ❌ b 2❗️❗️
😀 🔡 1 👈 4❗️❗️
😀 🔡 256 👉 2❗️❗️
🍉1000 1110 110 16 64
Negating a number (🔋)
🔋 number❗️ gives the value with its sign flipped (-x).
🏁 🍇
5 ➡️ n
😀 🔡 🔋 n❗️❗️❗️
😀 🔡 🔋 2.5❗️ 1❗️❗️
🍉-5 -2.5
Math functions
Real numbers (💯) have math functions available as methods.
| Syntax | Meaning |
|---|---|
⛷ x❗️ |
square root |
🏂 x y❗️ |
x to the power of y |
🏧 x❗️ |
absolute value (integers have it too) |
📓 x❗️ 📕 x❗️ 📐 x❗️ |
sin, cos, tan |
🔢 x❗️ |
convert to an integer (drops the fractional part) |
🏁 🍇
😀 🔡 ⛷ 2.0❗️ 4❗️❗️
😀 🔡 🏂 2.0 10.0❗️ 0❗️❗️
😀 🔡 🏧 -7❗️❗️❗️
😀 🔡 🔢 3.9❗️❗️❗️
🍉1.4142 1024 7 3