Numbered Steps to Reproduce Problem:
- Attempt to use bitwise AND on a variable and the literal value 0xFFFF
- Notice that the result is merely the value of the variable
Code Snippet (if applicable) to Reproduce Problem:
/world/New()
var/a = 0x10000
var/b = 0xFFFF
world.log << "[0xFFFF & 0x10000]" // output "0"
world.log << "[0xFFFF & a]" // output "65536"
world.log << "[ b & 0x10000]" // output "0"
world.log << "[ b & a]" // output "0"
Expected output of the above is four identical lines "0", given that all lines are identical if the values of variables are substituted for the variables.
Expected Results: Bitwise operations would return values with zeroed-out upper bits, so that the result is the same as if the operations were performed on 16-bit integers.
Actual Results: Bitwise AND applied to the literal value 0xFFFF and a variable returns the value of the variable.
Does the problem occur:
Every time? Or how often? Every time
In other games? N/A
In other user accounts? Unknown
On other computers? Unknown
When does the problem NOT occur? N/A
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? Unknown
Workarounds: Use % 0x10000 instead?
More cases, including with vars declared const:
/world/New()
var/a = 0x10000
var/b = 0xFFFF
var/const/ca = 0x10000
var/const/cb = 0xFFFF
world.log << "[0xFFFF & 0x10000]" // 0
world.log << "[0xFFFF & a]" // 65536
world.log << "[0xFFFF & ca]" // 0
world.log << "[ b & 0x10000]" // 0
world.log << "[ cb & 0x10000]" // 0
world.log << "[ a & b]" // 0
world.log << "[ a & cb]" // 65536
world.log << "[ca & b]" // 0
world.log << "[ca & cb]" // 0