[2.1.11] Entering hexadecimal numbers to number fields does not correctly handle sign
Posted: Sun Jul 19, 2026 6:29 am
What did you do?
Tried to use a bitwise AND operation to isolate the most significant bit of a signal and entered 0x80000000 for the constant. Discovered on 2.0.77 with mods and tested again on 2.1.11 (Linux) without mods.
What happened?
The hexadecimal input of the constant was interpreted as maximum signed integer (2147483647).
What did you expect to happen instead?
I expected the hexadecimal input to be interpreted as raw binary which then gets represented in the game as a signed integer. I expected to get a -2147483648 by entering 0x80000000.
Does it happen always, once, or sometimes?
Happens always.
More detail:
When entering a hexadecimal constant into a number field, entering 0x80000000 returns 2147483647 instead of -2147483648. Same for any hexadecimal number >0x7FFFFFFF
Hexadecimal value entered into field: Resulting decimal constant The main use case I see for using the hexadecimal input is for handling bitwise operations (which is where I discovered this), and this makes it extremely annoying to interact with the most significant bit of the signal, requiring manually entering the appropriate negative decimal if your constant includes a 1 in the MSB. For example, you need to manually enter -2147483648 if you wish to do the following bitwise and operation for isolating the most significant bit:
signal-0 AND 0x80000000
Tried to use a bitwise AND operation to isolate the most significant bit of a signal and entered 0x80000000 for the constant. Discovered on 2.0.77 with mods and tested again on 2.1.11 (Linux) without mods.
What happened?
The hexadecimal input of the constant was interpreted as maximum signed integer (2147483647).
What did you expect to happen instead?
I expected the hexadecimal input to be interpreted as raw binary which then gets represented in the game as a signed integer. I expected to get a -2147483648 by entering 0x80000000.
Does it happen always, once, or sometimes?
Happens always.
More detail:
When entering a hexadecimal constant into a number field, entering 0x80000000 returns 2147483647 instead of -2147483648. Same for any hexadecimal number >0x7FFFFFFF
Hexadecimal value entered into field: Resulting decimal constant The main use case I see for using the hexadecimal input is for handling bitwise operations (which is where I discovered this), and this makes it extremely annoying to interact with the most significant bit of the signal, requiring manually entering the appropriate negative decimal if your constant includes a 1 in the MSB. For example, you need to manually enter -2147483648 if you wish to do the following bitwise and operation for isolating the most significant bit:
signal-0 AND 0x80000000