| View previous topic :: View next topic |
| Author |
Message |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Thu Aug 25, 2005 11:09 pm Post subject: shift and bitwise comparison |
|
|
how can i implement
| Quote: | op1 | op2 Bitwise OR if both operands are numbers;
conditional OR if both operands are boolean |
in lua? seems that this is not implemented as default
further i'm missing the shift
| Quote: | | op1 << op2 Shift bits of op1 left by distance op2; fills with zero bits on the right-hand side |
shift could be possible solved by *2 and div2 thats right?
any ideas? |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Fri Aug 26, 2005 12:19 am Post subject: |
|
|
| Lua has no binary relational operators, but looks like it could be useful for some low-level calculations, so I've added the "Bitwise operators and hexadecimal support" patch from http://lua-users.org/wiki/LuaPowerPatches and it will be available in the next release, maybe this weekend. Of course, shift operators need no patch, because x << y == x * math.pow(2, y) and x >> y == math.floor(x / math.pow(2, y)). |
|
| Back to top |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Fri Aug 26, 2005 12:24 am Post subject: |
|
|
| great thanks |
|
| Back to top |
|
 |
Arwin
Joined: 12 Jul 2005 Posts: 426
|
Posted: Fri Aug 26, 2005 12:38 am Post subject: |
|
|
| Shine wrote: | | Lua has no binary relational operators, but looks like it could be useful for some low-level calculations, so I've added the "Bitwise operators and hexadecimal support" patch from http://lua-users.org/wiki/LuaPowerPatches and it will be available in the next release, maybe this weekend. Of course, shift operators need no patch, because x << y == x * math.pow(2, y) and x >> y == math.floor(x / math.pow(2, y)). |
Cool! That would solve most of my lua p-sprint problems at the same time. |
|
| Back to top |
|
 |
MikeHaggar
Joined: 18 Jul 2005 Posts: 116
|
Posted: Fri Aug 26, 2005 4:31 am Post subject: |
|
|
| Hmm... That hexadesimal stuff might be useful for my textreader ;) |
|
| Back to top |
|
 |
|