Factorio

Factorio

View Stats:
{null} Apr 29, 2022 @ 10:36am
>> and <<
I saw these in the arithmetic combinator, does anyone know what they do?
< >
Showing 1-9 of 9 comments
AlexMBrennan Apr 29, 2022 @ 10:37am 
Those are bit shift operators.

https://wiki.factorio.com/Arithmetic_combinator
{null} Apr 29, 2022 @ 10:40am 
Thanks, I did think they had something to with powers of 2
knighttemplar1960 Apr 29, 2022 @ 12:26pm 
If you are unfamiliar with boolean operations you can think of it as kind of a word problem from elementary math as an IF/THEN statement.

You have 3 boolean operators AND, OR, and NOT.

IF X=? AND Y=? THEN Z=? for the statement (Z) to return TRUE both conditions have to be true.
IF X=? OR Y=? THEN Z=? for the statement (Z) to return TRUE either of the conditions have to be true.
IF X=? NOT Y=? THEN Z=? for the statement (Z) to return TRUE both conditions have to be false.
{null} Apr 29, 2022 @ 1:55pm 
I am familiar with boolean operations (some you haven't mentioned are XOR, NAND, and NOR), just not the bit shift operations, as well, you seem to be confusing NOT with NOR (NOT is an unary operation, your description of NOT seems to match NOR), also, if you are talking about logical implies, then, in the case of X IMPLIES Y, it is not that X has to be true for Y to be true, but rather Y has to be true for X to be true.
Fel Apr 29, 2022 @ 4:14pm 
To be fair, bitwise operations are only used in complex setup in this game, when you are trying to store and encode a lot of information in a single signal for example.
This used to be necessary when making trains go to stations based on offer and demand for example but that was simplified when the devs added the train limits.
robfilrhijar Apr 29, 2022 @ 8:22pm 
And all along i thought it meant left or right...
DCYW Apr 29, 2022 @ 8:25pm 
Had you played Shapez.io or OpenTTD games yet?.
I think those game might give you idea how wires and operators work.
I put it this way in Factorio wise operators.

Factory Items >> IF X=A AND Y=B Then Z=AB << IF-THEN statement
Trains >> A AND B go to AB << GO-TO statement

NOT gates are inverters which implies to both items (not same output the other) and trains (not same items transported do not go to base).

Trains may use IF-THEN statements only if items are stored in storage chests or whatever chests you built besides stops then go to base with items transported. Yes, left and right directions is one of them like driving your car, tank, or buggy for instance.
Last edited by DCYW; Apr 29, 2022 @ 9:54pm
Fel Apr 29, 2022 @ 8:38pm 
Well, it does mean left and right since it moves the bits left and right respectively.
Errata Apr 29, 2022 @ 10:18pm 
X<<Y is essentially the same as X * (2 ^ Y). X times two to the power of Y. X>>Y is X divided by 2 to the power of Y. The signals are only 32-bit integers, so the result may be truncated to fit that data type. It's called a bit shift operation because multiplying or dividing by a power of 2 is just moving the binary digits left or right.

The uses in game are pretty niche, but they can be useful if you know what you're doing. Instead of a single 32-bit number, you could think of a signal as an array of 32 1-bit true or false flags. Or 16 2-bit values, 8 4-bit values, etc. For a representation like that, shifting may be important to be able to get at the right field of that array. If you want a static element, you could just do the math in your head, but if you want to do it dynamically based on some other variable, you need to shift it.
< >
Showing 1-9 of 9 comments
Per page: 1530 50

Date Posted: Apr 29, 2022 @ 10:36am
Posts: 9