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

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

thanks

## lua translation

### Re: lua translation

This could be something like this:
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.

Code: Select all

```
;numerator = (0-bit32.band(bit32.bnot(numerator-1), 0x7FFFFFFF))
numerator = (0- ( ~(numerator-1)& 0x7FFFFFFF))
```

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.

### Re: lua translation

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