Binary Decoder

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
Endus322
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun Nov 27, 2016 5:59 pm
Contact:

Binary Decoder

Post by Endus322 »

Ive been looking at all the binary decoders, but not a single one has shown fully what they have done? Ive seen a design with two constants, and an arithmetic, but they dont show the second constant or the arithmetic. Im not sure if it still works, but I would like to know what is in the arithmetic and constant. - Endus322

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Binary Decoder

Post by DaveMcW »

The constants are 2^n, the arithmetic is EACH * Input. The result is negative numbers for 1, and positive numbers for 0.

Endus322
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun Nov 27, 2016 5:59 pm
Contact:

Re: Binary Decoder

Post by Endus322 »

DaveMcW wrote:The constants are 2^n, the arithmetic is EACH * Input. The result is negative numbers for 1, and positive numbers for 0.
so one constant is set to my binary number, what do i set as n. Arithmetic is set to each * blue (blue is binary number), what item do i do for the 2^n

Edit: Do i set the lamps to = 1,2,4,8,16,32 ect, and start from the right side?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Binary Decoder

Post by DaveMcW »

You need 32 constants, from 2^0 to 2^31.

frequentPhoenix
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Aug 23, 2023 8:55 pm
Contact:

Re: Binary Decoder

Post by frequentPhoenix »

These topics give me the same confusion. This is some help, but still. Is one constant the "target number" and the other the "2^n" constants? like actually typed out, 0, 1, 2, 4, the rest. Do they all have to be the same signal?

Working blueprint or picture with details much appreciated.

Premu
Fast Inserter
Fast Inserter
Posts: 100
Joined: Wed Nov 13, 2019 4:40 pm
Contact:

Re: Binary Decoder

Post by Premu »

Hm, what exactly do you want to achieve? Which problem do you want to solve?

In general:
To set a single bit in a signal, you have to do a bitwise OR with the appropriate number (meaning 1,2,4,8,etc. - it has to be 2^n)
To check if a bit is set, you have to do a bitwise AND with that number.

StilI it's important to know what you want to actually do. I use a bitwise signal to activate target stations for my recycling train based on the trains content, for example. But my solution might not work for you at all.

Post Reply

Return to “Gameplay Help”