shift and bitwise comparison

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

shift and bitwise comparison

Post by LuMo »

how can i implement
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
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?
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

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)).
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

great thanks
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

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.
MikeHaggar
Posts: 116
Joined: Mon Jul 18, 2005 2:20 am

Post by MikeHaggar »

Hmm... That hexadesimal stuff might be useful for my textreader ;)
Post Reply