Binary decoder

Post pictures and videos of your factories.
If possible, please post also the blueprints/maps of your creations!
For art/design etc. you can go to Fan Art.

jo2k
Burner Inserter
Burner Inserter
Posts: 11
Joined: Wed Oct 05, 2016 8:04 pm
Contact:

Re: Binary decoder

Post by jo2k »

This combinator stuff is very nice. Especially if you use them with the knowledge of the integer overflow quirk.
Large displays with 1 combinator per row are really easy now. Yeah. :-)

For those, who hasn't understood how it works (like me), I wrote this little tool (C code, 32bit int, q&d) that helped me to open my eyes.
Thanks, XKnight.

Code: Select all

#include <stdio.h>

int main()
{
    int c = 1;
    int i = 0;

    int in = 0;
    int tmp = 0;
    int bit = 0;

    do
    {
        printf("In: ");
        scanf("%d", &in);
        if(in == 0) break;

        c = 1;
        for(i = 32; i > 0; i--)
        {
            tmp = c * in;
            bit = (tmp < 0);
            printf("%2d: %11d -> %11d = %d\n", i, c, tmp, bit);
            c = c * 2;
        }
    } while(1);

    return 0;
}
@Amegatron: I hope you found your mistake in the meantime, because -2147483647 isn't the correct number. If you use the correct factor for every bit, then you will never get an incorrect decoding. ;-)

User avatar
ShinoHarvest
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Tue May 08, 2018 3:29 pm
Contact:

Re: Binary decoder

Post by ShinoHarvest »

in solo game 2147483647 + 1 = 2147483648
dedicated serv 2147483647+1 = -2147483648

>_<

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

Re: Binary decoder

Post by frequentPhoenix »

I have tried and failed to make XKnight's decoder. Can anyone post non-cryptic information for the rest of us?

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

Re: Binary decoder

Post by Tertius »

In the thread below, there is an extended discussion about bit manipulation and a binary decoder is developed by the people, essentially duplicating some discussion from this thread and developing the same decoder in the end. The advantage of that thread is there survived many images and there are a lot of blueprints.
I link my post that contains some kind of conclusion and the decoder you're asking about. Scroll backwards and you have the whole discussion.

About the blueprint in that post: Ignore the rightmost 2 combinators, they're only for producing the visualization of the two's complement. The actual decoder for the number is only the 2 constant combinators with the left arithmethic combinator, as mentioned in this thread, and extended to 32-bit.
In case it isn't clear: inspect not only the combinator, inspect the conditions in all the lamps as well. They're essential.

viewtopic.php?p=557512#p557512

Nidan
Fast Inserter
Fast Inserter
Posts: 225
Joined: Sat Nov 21, 2015 1:40 am
Contact:

Re: Binary decoder

Post by Nidan »

frequentPhoenix wrote:
Wed Aug 23, 2023 9:21 pm
I have tried and failed to make XKnight's decoder. Can anyone post non-cryptic information for the rest of us?
Those posts are quite old. Since then combinators gained the ability to do bitwise logic, making the old designs obsolete unless you want to learn the trickery they used. In current factorio a combinator set to AND will do.

Post Reply

Return to “Show your Creations”