The Hacker's Language in Action: #2 Beautiful numbers
Lua language has a delicate treatment for mathematical operations in order to simplify your life.
Arithmetic operators
![lua_arithmetics.png](https://steemitimages.com/640x0/https://steemitimages.com/DQmbDzuq7QwRyqZjkwoqfcq94K7aSjeNPG3c6jhPZQe4f2b/lua_arithmetics.png)
note difference type vs math.type
Exponentiation and useful modulo
![lua_useful_modulo.png](https://steemitimages.com/DQmdrQPUh58mAfotr2SYubgCLMyAz5K9qS24H4pZ1cZsr2d/lua_useful_modulo.png)
Basics maths functions
![lua_basics_maths.png](https://steemitimages.com/640x0/https://steemitimages.com/DQmcu4axqnAc1vDxevT2mhBcG8mwagUicSUstEwPTox8oLc/lua_basics_maths.png)
Precedence
No | Description |
---|---|
1 | ^ |
2 | unary operators (-, ~, #, not) |
3 | /, //, *, % |
4 | +, - |
5 | .. (concatenation) |
6 | <<, >> (bitwise shifts) |
7 | & (bitwise AND) |
8 | ~ (bitwise exclusive OR) |
9 | ▏(bitwise OR) |
10 | <, >, <=, >=, ==, ~= |
11 | and |
12 | or |
- Roberto Ierusalimschy, Programming in Lua, Fourth Edition.
- lua.org
Previous post
hey sorry to go off topic, i needed some help with steem python ,r u der on discord or steemit chat?
Hi, i'm sorry (long time), i'm reading about steem python, what happen?