Factorio

Factorio

View Stats:
MAKAIROSI Sep 3, 2019 @ 8:03am
What does XOR do in factorio exactly?
I mean, i know it takes booleans and returns true if their odd number is true. So i thought that a XOR gate would only take 0 or 1 for inputs, so anything other 1 (or further from 1) would be a 0. However it doesn't seem to work that way (-1 XOR 1 gave me -2 i think - i may be wrong i don't remember the exact number it gave me but i was expecting a 1 anyway). Then i tested it with accumulator charges so that i had kind of random numbers.

If i remember correctly, 100 XOR 52 gave me something like 97. So this is why i'm asking how exactly does it work? I mean what calculation did it do to result in 97?
< >
Showing 1-5 of 5 comments
Fel Sep 3, 2019 @ 8:19am 
Source: https://wiki.factorio.com/Tutorial:Combinator_tutorial
The arithmetic combinator has built in OR, XOR and AND operators. These operate bitwise, i.e. they perform the operation on each bit in the number in a binary format and return the result.

100 > 1100100
52 > 0110100

XOR from those two:
1100100
0110100

1010000 > 80
MAKAIROSI Sep 3, 2019 @ 8:24am 
Ah thanks. I didn't know they operated bitwise. I thought they only accepted 1 for true and 0 for false.
piccolo255 Sep 3, 2019 @ 8:25am 
Originally posted by MAKAIROSI:
If i remember correctly, 100 XOR 52 gave me something like 97. So this is why i'm asking how exactly does it work? I mean what calculation did it do to result in 97?
Do you mean 100 XOR 5? That gives 97, while 100 XOR 52 should give 80.

See here for the "bitwise XOR": https://en.wikipedia.org/wiki/Bitwise_operation#XOR
And here for binary representation you need to get those bits: https://en.wikipedia.org/wiki/Binary_number#Decimal

Windows calculator* also has a "programmer mode" (View > Programmer) where you can see the binary representations. It also has bitwise operations, including XOR.

---
*At least the Win7 one does. Don't know about the "new and improved" Win10 version.
Last edited by piccolo255; Sep 3, 2019 @ 9:55am
Fel Sep 3, 2019 @ 9:02am 
I can confirm that the windows calculator still has the bitwise XOR.

By the way, all of the operations of the arithmic combinator starting from the << (left bit shift) work with the binary value of the signals.
MAKAIROSI Sep 3, 2019 @ 10:28am 
Originally posted by Fel:
I can confirm that the windows calculator still has the bitwise XOR.

By the way, all of the operations of the arithmic combinator starting from the << (left bit shift) work with the binary value of the signals.

I understood that for << and >> but i didn't know it worked like that for XOR.
< >
Showing 1-5 of 5 comments
Per page: 1530 50

Date Posted: Sep 3, 2019 @ 8:03am
Posts: 5