[1.1.72] Operation AND in arithmetic combinator works incorrect

Bugs that are actually features.
Post Reply
wwwitalya
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Dec 08, 2022 11:23 am
Contact:

[1.1.72] Operation AND in arithmetic combinator works incorrect

Post by wwwitalya »

Operation "AND" in arithmetic combinator compare both signals and its values, but it`s looks like it should check only exist of signals, because functional of checking signal and its value already exist in decider combinator.

I mean when we send for example "A10" and "B1" to arithmetic combinator with "A and B"-condition it should return "true" (whatever you want in output, of cource), because we have A and B on input.
If we want to check signal and its count together we can use decider combinator with "A=B"-condition.

Blueprint

Code: Select all

H4sIAAAAAAAA/8WTb2vbMBDGv0rQa6nYCekGRYV9jlCMKl26A/2bJJcE4e/ei+KNOdtKUgZ9Zc53fu7R77FMWNmglV0NsoIvWBCyrNUrB5IZ0GggCR3cM3pV
QmI8hkxDwct6kGJ7t+VHKfqJG0yg2/s118H7c0FSO9azJ1kTGJJtG44DGrmeponv2PpvvS3XmPSI5VT002mSJA3OirMrWfeYchkyvnhlZS3HSJaxgGP8bB9T
8CJaVYA1hVyUL7LvOipcVOl0IMkeGQ9jieOl0iumMir7U+zcFN+aVDwOOoy+DPsU3ICevpZsr2ymTeR2xmfDC+aCWujvkItI8GOkJ1xC/EoIu+kqav2SDP+t
tfkD2i8fV8b4wRQ/GA5BjOTpE+NxYHB0AiydMlFKMVi4ALNp0VwNsmscu9s5LnJ972p8uQ34e5Bm3kva8hNp3y9hZ6esFVa5uBy74bpsL7Eu0c3N/4TukbUF
qJt2RW/gQMH+88+h4YcEZUx+NTyAN282PNLnigUAAA==
Attachments
2022-12-08_18-19-23.png
2022-12-08_18-19-23.png (278.18 KiB) Viewed 1045 times

Genhis
Factorio Staff
Factorio Staff
Posts: 120
Joined: Wed Dec 24, 2014 8:19 am
Contact:

Re: [1.1.72] Operation AND in arithmetic combinator works incorrect

Post by Genhis »

Thanks for the report. The operation is a bitwise AND and works as intended. It performs logical AND on individual bits, so 10 and 1 (in decimal) = 1010 and 0001 (in binary) = 0000.

wwwitalya
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Dec 08, 2022 11:23 am
Contact:

Re: [1.1.72] Operation AND in arithmetic combinator works incorrect

Post by wwwitalya »

But arithmetic combinator shouldn`t compare value of signals at all, it`s decider combinator`s functional.
Arithmetic combinator with "AND" operation should check only input`s signal exist, that`s point.
Otherwise, you have two different entities with identical functional.
1st screenshot - arithmetic combinator has A1 and B1 on input and "check" in output - it`s correct.
2022-12-08_20-20-16.png
2022-12-08_20-20-16.png (270.81 KiB) Viewed 978 times
2nd screenshot - decider has A1 and B1 on input and "check" in output - it`s correct too.
2022-12-08_20-22-24.png
2022-12-08_20-22-24.png (239.55 KiB) Viewed 978 times
3rd screenshot - arithmetic combinator has A1 and B2 on input and nothing in output - it`s wrong, should be "check", because it has A AND B on input.
2022-12-08_20-21-18.png
2022-12-08_20-21-18.png (241.99 KiB) Viewed 978 times

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2250
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.1.72] Operation AND in arithmetic combinator works incorrect

Post by boskid »

Genhis is correct. This is not a bug. Arithmetic combinator is not working on signal presence but it is doing a bitwise AND operation on those signal values and all values in your screenshots are correct. By doing (X AND Y) where Y=1 that arithmetic basically extracts lowest bit of the signal X which for odd values of X (like 1) is 1 but for even values of X (like 2 or 10) is 0.

Tertius
Filter Inserter
Filter Inserter
Posts: 671
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: [1.1.72] Operation AND in arithmetic combinator works incorrect

Post by Tertius »

The bitwise AND operation is no comparison operator. It's an arithmetic operator like +, -, *, / but with its own special rule of operation.
For every pair of bits in the input operators, it outputs a 1 if both input bits are 1, and 0 otherwise.

Example:

Code: Select all

input A  78 -> 01001110
input B 172 -> 10101100
-----------------------
output         00001100 -> 12
Only bits 2 and 3 are 1 for both numbers, so they are output as 1. The decimal interpretion of 00001100 is 12, so the combinator would output 12 if gets inputs 78 and 172.

The combinators have no notion of a value being "true" or "false". It's common to define 0 as false and everything else as true, but this is just an convention outside of Factorio. The combinators don't interpret values as such. For these, only the result of a comparison is true or false.

So if you want to decide if two signals are both nonzero or not, you need some computation. First you need a computation that interprets the value, then a comparison to create the true/false condition.
For example, you can use a decider combinator with the EACH operator as input to handle all input signals simultaneously. As condition, use <> 0. As output, enter some signal, for example Z as output, and 1 as output value. This way, for each of the input signal that is not 0, a 1 is output. Since all is output to Z, it's added up, so all 1 are summed up, so you get the number of inputs that are nonzero. It's a counter how many inputs are nonzero.
Now you just need to compare Z=2 or Z>=2 or whatever in an additional combinator or directly in the circuit that acts upon the final condition, to check how many different input signals you got.

wwwitalya
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Dec 08, 2022 11:23 am
Contact:

Re: [1.1.72] Operation AND in arithmetic combinator works incorrect

Post by wwwitalya »

Thanks for explanation, I was sure this is logic operation, my bad.

Post Reply

Return to “Not a bug”