Page 2 of 2

Re: Binary decoder

Posted: Wed Oct 05, 2016 8:33 pm
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. ;-)

Re: Binary decoder

Posted: Fri Jun 01, 2018 2:07 am
by ShinoHarvest
in solo game 2147483647 + 1 = 2147483648
dedicated serv 2147483647+1 = -2147483648

>_<

Re: Binary decoder

Posted: Wed Aug 23, 2023 9:21 pm
by frequentPhoenix
I have tried and failed to make XKnight's decoder. Can anyone post non-cryptic information for the rest of us?

Re: Binary decoder

Posted: Thu Aug 24, 2023 11:10 pm
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

Re: Binary decoder

Posted: Fri Aug 25, 2023 10:40 am
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.