lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


We've modified the Lua core to support C-style bitwise operators at our
company. It is not such a big/difficult change. I could probably produce a
patch if anyone is interested.

Eric

> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Philippe Lhoste
> Sent: Wednesday, September 19, 2001 1:50 AM
> To: Multiple recipients of list
> Subject: RE: Bitwise operations and binary number
>
>
> nerurin@hotmail.com wrote:
> > I wonder if Lua supports binary number and bitwise operations or not.
> [snip]
> > I do aware there is alternative to archive this. But I am just
> > interested in whether binary number works in Lua or not.
>
> Basically, Lua doesn't support bitwise operations. I asked often
> to add them
> (in the core, not in the libraries), as it is not so hard to do
> but need to
> manage some other special characters if we want to have the same
> syntax as in
> C. That's probably the reason why my plea is rejected. That, and the fact
> that basically, Lua works on float numbers, so isn't much bitwise
> oriented. But
> having this natively would allow some operations on binary files, for
> example.
>
> Otherwise, Reuben Thomas (http://www.dcs.gla.ac.uk/~rrt/) wrote a library
> for performing bitwise operations, that's exactly what you are
> looking for.
>
> And despite what I wrote some time ago, bitwise operations can be done on
> pure Lua. I began to write some routines to play with this (since
> Jean-Claude
> Wippler asked if it is possible for its MD5 routines), but it is
> currently a
> sleeping project. Quite operational, but some bugs are still
> crawling, as I
> don't handle signed numbers very well. I will revive this project
> after some
> others (the syntax highlighting of Lua in HTML, among others...).
>
> Of course, my routines are more a proof of concept that real useful code,
> since it is slow and memory consuming: I transform numbers in
> arrays of 1 and
> 0... I wrote a kind of "binary data" type, allowing, multiples operations
> without breaking down numbers each time, but I will write also
> the operations as
> taking one or two numbers and converting them back and forth on the fly.
> As I said, not very usable, except perhaps for very small use
> (like needing
> to apply a mask once in a program).
>
> Regards.
>
> --
> --._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.--
> Philippe Lhoste (Paris -- France)
> Professional programmer and amateur artist
> http://jove.prohosting.com/~philho/
> --´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`--
>
> Sent through GMX FreeMail - http://www.gmx.net