In other languages: Čeština Deutsch Français 日本語 Polski Русский Українська 简体中文

Decider combinator and Arithmetic combinator: Difference between pages

From Official Factorio Wiki
(Difference between pages)
Jump to navigation Jump to search
Mefisto1029 (talk | contribs)
 
History: 2.0.67 wire connection point offset
 
Line 1: Line 1:
{{Languages}}
{{Languages}}
{{:Infobox:Decider combinator}}
{{:Infobox:Arithmetic combinator}}
The '''arithmetic combinator''' is part of the [[circuit network]] and one of four types of combinators available in the game (along with the [[constant combinator]], [[decider combinator]], and [[selector combinator]]). Each arithmetic combinator can perform any one of the following mathematical operations on signals, and will show the corresponding symbol on its top:


The '''decider combinator''' is part of the circuit network and one of four types of combinators available in the game (with the other three being the [[constant combinator]], [[arithmetic combinator]], and [[selector combinator]]). It is used to make comparisons of signals on the network.
[[File:arith_combinator_anim.png]]
 
* addition (<span style="color:yellow">+</span>)
* subtraction (<span style="color:yellow">−</span>)
* multiplication (<span style="color:yellow">*</span>)
* division (<span style="color:yellow">/</span>)
* modulo (<span style="color:yellow">%</span>)
* exponentiation (<span style="color:yellow">^</span>)
* bit shift left (<span style="color:cyan"><<</span>)
* bit shift right (<span style="color:cyan">>></span>)
* bitwise AND (<span style="color:cyan">&</span>)
* bitwise OR (<span style="color:cyan">|</span>)
* bitwise XOR (<span style="color:cyan">^</span>)
 
The arithmetic combinator accepts two input connections (red and green wires), and sends its output to both output connections. The input wires connect to the nubs on the left side of the sprite in the sidebar, while the outputs connect to the right side.
 
[[File:Arithmetic_combinator_gui.png|350px|GUI of the Arithmetic Combinator.]]<br />


== Function ==
== Function ==
The decider combinator allows specifying a list of conditions on the left side of the GUI and a list of outputs on the right side of the GUI. Generally whenever the conditions are satisfied the outputs are activated.
The operands can be any single signal or a constant value. Up to one of the operands can be the [[Virtual signals#Each|''each'' virtual signal]]. For each signal operand, the input wires can be selected. If both wires are selected, the inputs are summed.
 
A condition consists of a "first" input signal, a comparison (>, <, =, >=, <=, !=), and a "second" input signal or constant. Additionally, for each input signal the input wires to read the signal from can be specified. If both red and green are checked, the input values are summed.


If more than one condition is added, it is possible to change the connection of those using the logical operators AND and OR. An AND condition will result in true if all terms are true. An OR condition will return true if at least one of the terms is true.
If neither operand is the ''each'' signal, the output must be a single signal. The operation is performed on the values of the chosen left and right signals, and the result is sent to the output on the specified signal.


Each output has the option to specify a constant value, or to take the input count from specified wires. If both red and green are checked, the input values are summed.
If one operand is the ''each'' signal, then the output can be a single signal or the ''each'' signal. If the output is the ''each'' signal, then the operation is performed individually on the value of each input signal along with the value of the other operand, and each result is sent to the output on the same signal. If the output is a single signal, the operation is done on each of the input signals, the individual results are all added together, and that result is sent to the output on the specified signal.


The decider combinator can handle [[Circuit network#Logic signals|logic signals]]. <span id="output table"></span>The following table shows how different combinations of logic signals can be used:
== Notes on operations ==
When using '''division''', the result is truncated:
* 21 / 10 = 2
* 19 / 10 = 1
* −21 / 10 = −2
* −19 / 10 = −1
* 21 / −10 = −2
* 19 / −10 = −1
* −21 / −10 = 2
* −19 / −10 = 1


{| class="wikitable" style="text-align: center"
'''Modulo''', indicated using % as it is in most programming languages, is the remainder after division. For example, 13 % 3 is 1 (13 = 4 * 3 + 1). This can, for example, be combined with truncated division as described above to separate out individual digits of a number for use in building visual indicators:
|+Different output results when the conditions pass
* (24321 / 10000) % 10  = 2
|-
* (24321 / 1000) % 10  = 4
! align=right | Input&nbsp;→
* (24321 / 100) % 10  = 3
!! rowspan=2 | No <span style="color:#FFFF99">Each</span> condition
* (24321 / 10) % 10  = 2
!! rowspan=2 | <span style="color:#FFFF99">Each</span> condition present
* (24321 / 1) % 10  = 1
|-
! align=left | ↓&nbsp;Output
|-
!style="text-align: left"| <span style="color:#FF6666">Everything</span>
| Evaluated on every signal that has a non-zero sum on the selected wires<sup>†</sup>
| -
|-
!style="text-align: left"| <span style="color:#99FF99">Anything</span>
| Evaluated on one signal that has a non-zero sum on the selected wires<sup>†</sup>
| Evaluated on one signal that passes the <span style="color:#FFFF99">Each</span> conditions
|-
!style="text-align: left"| <span style="color:#FFFF99">Each</span>
| -
| Evaluated on <span style="color:#FFFF99">Each</span> passing signal
|-
!style="text-align: left"| Specific signal
| Evaluated on the specified signal
| Evaluated on <span style="color:#FFFF99">Each</span> passing signal, but the results are output on the specified signal instead
|-
|}


<sup>†</sup> wires can be selected even if a constant value is specified
Negating the left operand of a modulo negates the result, while negating the right operand does nothing:
* 13 % 3 = 1
* 13 % −3 = 1
* −13 % 3 = −1
* −13 % −3 = −1


With both the arithmetic and decider combinator, there is one tick (60th of a second) of latency before the output signal is ready to be used as an input into a circuit network.
'''Bit shift right''' and '''Bit shift left''' deal with numbers in the [[:Wikipedia:Binary_number|binary]] representation. The 0's and 1's that make up a number are shifted in the specified direction which can result in a completely different number, due to the change in the binary value. The shift performed is called arithmetic shift, because it preserves the sign bit on bit shift right.
If shifting left, a 0 is inserted into the least significant bit (LSB), and the bit in the most significant bit (MSB) is lost.
If shifting right and the number is positive (MSB=0), a 0 is inserted into the MSB and the bit in the LSB is lost.
If shifting right and the number is negative (MSB=1), a 1 is inserted into the MSB to keep the sign and the bit in the LSB is lost.
[[File:Bitshiftleft.png|none|thumb|200px|Example of a 'bit shift left'.]] [[File:BitshiftRightZero.png|none|thumb|200px|Example of a 'bit shift right (positive number)'.]] [[File:BitshiftRightOne.png|none|thumb|200px|Example of a 'bit shift right (negative number)'.]]


== History ==
== History ==
{{history|2.0.36|
{{history|2.0.67|
* Decider combinator output constant can be changed.
* Fixed combinator's red and green wires would overlap when built vertically.}}
}}


{{history|2.0.7|
{{history|2.0.7|
Line 55: Line 66:
** Now displays input signals when configuring combinators.
** Now displays input signals when configuring combinators.
** Signals used by combinators can now be filtered between red, green, or both.
** Signals used by combinators can now be filtered between red, green, or both.
** Multiple and/or operations can be performed in a single decider combinator.
}}
}}
{{history|1.1.13|
* Decider combinator can output an Anything signal, which returns exactly one matching signal.}}


{{history|0.15.0|
{{history|0.15.0|
* Added additional operators to the Decider Combinator and Circuit Conditions.}}
* Added Modulo, Power, Left Bit Shift, Right Bit Shift, Bitwise AND, Bitwise OR and Bitwise XOR to the Arithmetic Combinator.}}


{{history|0.13.0|
{{history|0.13.0|
Line 68: Line 75:
* Combinators show input and output in alt mode.
* Combinators show input and output in alt mode.
* More virtual signals for combinators.
* More virtual signals for combinators.
* Decider combinator "input count" option makes the combinator copy the count of the specified output signal from the input signals, instead of copying the count from the condition.
* New combinator graphics. }}
* New combinator graphics. }}


Line 80: Line 86:
* Introduced}}
* Introduced}}


== See also ==
==See also==
* [[Circuit network]]
* [[Circuit network]]
* [[Combinators]]
* [[Combinators]]
** [[Arithmetic combinator]]
** [[Decider combinator]]
** [[Constant combinator]]
** [[Constant combinator]]
** [[Selector combinator]]
** [[Selector combinator]]

Latest revision as of 04:12, 8 October 2025

Arithmetic combinator

Recipe

0.5
+
5
+
5
1

Total raw

8
+
10
+
5

Map color

Health

150
195 240
285 375

Stack size

50

Rocket capacity

50 (1 stack)

Energy consumption

1 kw (electric)

Mining time

0.1

Prototype type

arithmetic-combinator

Internal name

arithmetic-combinator

Required technologies

Produced by

The arithmetic combinator is part of the circuit network and one of four types of combinators available in the game (along with the constant combinator, decider combinator, and selector combinator). Each arithmetic combinator can perform any one of the following mathematical operations on signals, and will show the corresponding symbol on its top:

  • addition (+)
  • subtraction ()
  • multiplication (*)
  • division (/)
  • modulo (%)
  • exponentiation (^)
  • bit shift left (<<)
  • bit shift right (>>)
  • bitwise AND (&)
  • bitwise OR (|)
  • bitwise XOR (^)

The arithmetic combinator accepts two input connections (red and green wires), and sends its output to both output connections. The input wires connect to the nubs on the left side of the sprite in the sidebar, while the outputs connect to the right side.

GUI of the Arithmetic Combinator.

Function

The operands can be any single signal or a constant value. Up to one of the operands can be the each virtual signal. For each signal operand, the input wires can be selected. If both wires are selected, the inputs are summed.

If neither operand is the each signal, the output must be a single signal. The operation is performed on the values of the chosen left and right signals, and the result is sent to the output on the specified signal.

If one operand is the each signal, then the output can be a single signal or the each signal. If the output is the each signal, then the operation is performed individually on the value of each input signal along with the value of the other operand, and each result is sent to the output on the same signal. If the output is a single signal, the operation is done on each of the input signals, the individual results are all added together, and that result is sent to the output on the specified signal.

Notes on operations

When using division, the result is truncated:

  • 21 / 10 = 2
  • 19 / 10 = 1
  • −21 / 10 = −2
  • −19 / 10 = −1
  • 21 / −10 = −2
  • 19 / −10 = −1
  • −21 / −10 = 2
  • −19 / −10 = 1

Modulo, indicated using % as it is in most programming languages, is the remainder after division. For example, 13 % 3 is 1 (13 = 4 * 3 + 1). This can, for example, be combined with truncated division as described above to separate out individual digits of a number for use in building visual indicators:

  • (24321 / 10000) % 10 = 2
  • (24321 / 1000) % 10 = 4
  • (24321 / 100) % 10 = 3
  • (24321 / 10) % 10 = 2
  • (24321 / 1) % 10 = 1

Negating the left operand of a modulo negates the result, while negating the right operand does nothing:

  • 13 % 3 = 1
  • 13 % −3 = 1
  • −13 % 3 = −1
  • −13 % −3 = −1

Bit shift right and Bit shift left deal with numbers in the binary representation. The 0's and 1's that make up a number are shifted in the specified direction which can result in a completely different number, due to the change in the binary value. The shift performed is called arithmetic shift, because it preserves the sign bit on bit shift right. If shifting left, a 0 is inserted into the least significant bit (LSB), and the bit in the most significant bit (MSB) is lost. If shifting right and the number is positive (MSB=0), a 0 is inserted into the MSB and the bit in the LSB is lost. If shifting right and the number is negative (MSB=1), a 1 is inserted into the MSB to keep the sign and the bit in the LSB is lost.

Example of a 'bit shift left'.
Example of a 'bit shift right (positive number)'.
Example of a 'bit shift right (negative number)'.

History

  • 2.0.67:
    • Fixed combinator's red and green wires would overlap when built vertically.
  • 2.0.7:
    • Received a UI overhaul.
      • Now displays input signals when configuring combinators.
      • Signals used by combinators can now be filtered between red, green, or both.
  • 0.15.0:
    • Added Modulo, Power, Left Bit Shift, Right Bit Shift, Bitwise AND, Bitwise OR and Bitwise XOR to the Arithmetic Combinator.
  • 0.13.0:
    • Connected wires are highlighted when hovering over a combinator connected to the circuit network.
    • Combinators show input and output in alt mode.
    • More virtual signals for combinators.
    • New combinator graphics.
  • 0.12.5:
    • Combinators now emit light.
  • 0.12.2:
    • Combinators no longer turn off when no wires are connected.

See also