lua translation

Discuss any general programming issues here
Post Reply
ilbarbax
Posts: 146
Joined: Thu Apr 01, 2010 6:41 pm

lua translation

Post by ilbarbax »

How do you translate the following code from lua to Hollywood?

numerator = (0-bit32.band(bit32.bnot(numerator-1), 0x7FFFFFFF))

thanks
Flinx
Posts: 238
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: lua translation

Post by Flinx »

This could be something like this:

Code: Select all

;numerator = (0-bit32.band(bit32.bnot(numerator-1), 0x7FFFFFFF))
 numerator = (0-          (         ~(numerator-1)& 0x7FFFFFFF))
But without understanding what you are trying to achieve, it is always difficult to answer such a question.
I have searched and it looks like you tried to port the Exif parser from Github. I don't understand what they are doing there either.
But you should know that for a successful port it is usually necessary to understand what the code does. When you simply rewrite it in another language, errors are almost inevitable.
For example, the sign changes here due to the subtraction (0-...). This leads to different results in the internal representation of the number for different integer sizes. And since bit manipulations are also performed here, this is already a critical point, even if it looks as if both languages are dealing with 32-bit variables in this case.
ilbarbax
Posts: 146
Joined: Thu Apr 01, 2010 6:41 pm

Re: lua translation

Post by ilbarbax »

Yes i found a lua code for exif and i translated it to Hollywood furtherly inproving it. IIt works 80% but some data is not correctly interpreted and this is a line I do not understand and I was going to translate literally to see the effects and then work around
Post Reply