Open 2.2.2: Computercraft 1.74 has broken bitwise operations

KJ4IPS

New Member
Jul 29, 2019
1
0
0
Version:
2.2.2

What is the bug:
Summary
Computercraft 1.74 contains a broken implementation of the 'bit' api, which is used for bitwise operations.

Impact
This also breaks the colors.subtract routine, and all internal programs that rely upon it.

Thoughts
Due to the nature of the values returned, it is likley that an unsigned number is being interpreted as signed, or vice versa.

Workarounds
Code:
    bit.bnot = function(inWord)
       return bit.bxor(inWord, tonumber("FFFFFFFF", 16))
     end

side note: Why is there not a preview for bug reports?

Mod & Version:
Computercraft 1.74

Paste.feed-the-beast.com log:
[Not Applicable]

Can it be repeated:
Reproduction
Place a computercraft computer in the world, and open it's interface.
type "lua" and press enter to start the lua interpreter
enter the following:
Code:
bit.bnot(bit.bnot(2))
note that the result is not 2, as it should be (bitwise not is a symetic operation)

Note that this does return '2' when using the current (1.75) version of computercraft

Known Fix:
Update to CC's hotfix for this issue: 1.75
 
Last edited: