Page 1 of 2

Hex signal view, hex and mathematical input in constants

Posted: Mon Jul 20, 2020 10:33 pm
by ratelslangen
Dear development team,

I would like to suggest three things:
  • I want to be able to enter numbers in this form "2 ^ 24" and have it be converted to 16777216.
  • I want to be able to enter numbers in hex form (eg, 0xFF is 255).
The points above would help tremendously with complex circuitry.
  • I would like to have a toggle in the options to display circuit numbers in hex form, to aid in debugging.
Thank you.

Re: Hex signal view, hex and mathematical input in constants

Posted: Tue Jul 21, 2020 3:42 am
by ssilk
Why in hex? Not very useful. Is for 0xABCDE76 the 15th Bit set or not? If that will be implemented I would add binary input.

Re: Hex signal view, hex and mathematical input in constants

Posted: Tue Jul 21, 2020 4:58 pm
by bormand
ssilk wrote: Tue Jul 21, 2020 3:42 am Why in hex? Not very useful.
Because hex is very compact and people with programming background usually can convert between bin and hex on fly.

So, I vote for both 0xFF and 0b11111111.

P.S. Bit 17 of 0xABCDE76 is 1100 and bit 15 is 1101. Now try to find them in the 1010 1011 1100 1101 1110 0111 0110.

Re: Hex signal view, hex and mathematical input in constants

Posted: Wed Jul 22, 2020 4:32 am
by ssilk
It’s about comparability. Let’s say you want to program a LTN station, what’s easier?

Compare the wagon-mask with 0x0020000 to find the 17th wagon unloader. And 0x0040000 for the 18th. You need to think it all the time: 1, 2, 4, 8, then the next digit...

Or compare by using 0b0000 0000 0010 0000 0000 0000 0000 for the 17th, then copy that into buffer, go to next stop, paste, remove one 0 at front and add one 0 at the end. I would prefer this method, because I can’t make stupid mistakes. :)

... Ah. Now I see the sense of the other form you want to make inputs. “2^17”, “2^18”... and for bitmasks you can say “2^17 + 2^18” ...hm. Yes. :) I still think binary has it’s usecases, especially when taking an output and copy/paste it as input for something else. :P

BTW printing such numbers seems to be much more complex... but that’s normally not needed, and that is a completely different story - very old suggestions about seeing the actual non-abbreviated value and so on.

Re: Hex signal view, hex and mathematical input in constants

Posted: Wed Jul 22, 2020 5:52 am
by bormand
ssilk wrote: Wed Jul 22, 2020 4:32 amYou need to think it all the time: 1, 2, 4, 8, then the next digit...
You don't need to think about 1, 2, 4 and 8. Think in groups of 4 bits. You can look at the number 0xABCDE67 and see that unloaders for wagons 19 and 18 are active and for 17 and 16 are not (C=1100). And wagons 15, 14 and 12 are active too (D=1101). It takes a little practice to remember mapping between hex digits and their binary representations. But then you can read and write hex masks almost instantly.

In fact, binary is much more error prone to me. I always make stupid mistakes while counting those digits, especially if they aren't grouped.

That's why I suggest to add both formats. Both have their upsides and downsides.

Re: Hex signal view, hex and mathematical input in constants

Posted: Wed Jul 22, 2020 7:26 am
by foamy
bormand wrote: Wed Jul 22, 2020 5:52 am
ssilk wrote: Wed Jul 22, 2020 4:32 amYou need to think it all the time: 1, 2, 4, 8, then the next digit...
You don't need to think about 1, 2, 4 and 8. Think in groups of 4 bits. You can look at the number 0xABCDE67 and see that unloaders for wagons 19 and 18 are active and for 17 and 16 are not (C=1100). And wagons 15, 14 and 12 are active too (D=1101). It takes a little practice to remember mapping between hex digits and their binary representations. But then you can read and write hex masks almost instantly.

In fact, binary is much more error prone to me. I always make stupid mistakes while counting those digits, especially if they aren't grouped.

That's why I suggest to add both formats. Both have their upsides and downsides.
This. Hex translates easily and directly to binary, is more compact, and more readable and usable in nearly all cases. Memorizing the sixteen binary representations each hex digit encodes isn't difficult (and can be pretty easily worked out from first principles anyway), and anyone who wants to encode binary or hex numbers almost certainly knows how to do it.

Re: Hex signal view, hex and mathematical input in constants

Posted: Wed Jul 22, 2020 8:20 am
by coppercoil
I think the player cannot memorize sixteen representations if he uses them occasionally. Yes, he will know how to convert it using exernal tools, how about embedded tools? If we would have two display modes, why not to add the third one?

BTW every bit can be numbered, therefore no problems locating 15th bit.

Re: Hex signal view, hex and mathematical input in constants

Posted: Wed Jul 22, 2020 2:13 pm
by steinio
I would prefer a converter combinator which gets a value as input, has a setting for the target digit system (2/10/16) and outputs the value converted.

This has the advantage that it can be put everywhere in the circuit where a specific value is needed in an other digit system.

Re: Hex signal view, hex and mathematical input in constants

Posted: Wed Jul 22, 2020 2:32 pm
by netmand
Is this not possible as a mod?

Re: Hex signal view, hex and mathematical input in constants

Posted: Wed Jul 22, 2020 3:52 pm
by foamy
coppercoil wrote: Wed Jul 22, 2020 8:20 am I think the player cannot memorize sixteen representations if he uses them occasionally. Yes, he will know how to convert it using exernal tools, how about embedded tools? If we would have two display modes, why not to add the third one?

BTW every bit can be numbered, therefore no problems locating 15th bit.
I'd have no problems with a binary encode as well, but if I had to choose between hex and bin for a human-facing interface, it'd be hex every single time.

Re: Hex signal view, hex and mathematical input in constants

Posted: Wed Jul 22, 2020 4:18 pm
by bormand
netmand wrote: Wed Jul 22, 2020 2:32 pm Is this not possible as a mod?
Sure. Modded combinator that can set and display values in any format is certainly possible, at least.

Re: Hex signal view, hex and mathematical input in constants

Posted: Wed Jul 22, 2020 5:15 pm
by Optera
Having a combinator showing signals as bin or hex would already be a big qol improvement.

Entering numbers as hex though would make binary logic with circuits much simpler. I might even put windows calc away for generating overflow values.

Re: Hex signal view, hex and mathematical input in constants

Posted: Fri Jul 24, 2020 9:56 am
by Hannu
coppercoil wrote: Wed Jul 22, 2020 8:20 am I think the player cannot memorize sixteen representations if he uses them occasionally.
Probably significant part of Factorio players have some programming experience. In work, in studies or as a hobby. Programmers are familiar with hex system and can easily count bits. I prefer hex numbers over binaries if there is more than 8 bits, because it is somewhat difficult and very error prone to count for example 10 zeros before single set bit (10000000000 or 400). They need also less room to show. Factorio uses 32 bit integers and such binary number is very inconvenient compared to 8 number hexadecimal number.
If we would have two display modes, why not to add the third one?
This is true. It is good idea to include both if such modification is made. Additional work is small.

Re: Hex signal view, hex and mathematical input in constants

Posted: Fri Jul 24, 2020 4:59 pm
by coppercoil
Hannu wrote: Fri Jul 24, 2020 9:56 am Programmers are familiar with hex system and can easily count bits.
Programmers are familiar with hex system - yes.
Can easily count bits - no. Most programmers don't use bits often, thereby have no need to memorize them.

Re: Hex signal view, hex and mathematical input in constants

Posted: Fri Jul 24, 2020 5:21 pm
by foamy
coppercoil wrote: Fri Jul 24, 2020 4:59 pm
Hannu wrote: Fri Jul 24, 2020 9:56 am Programmers are familiar with hex system and can easily count bits.
Programmers are familiar with hex system - yes.
Can easily count bits - no. Most programmers don't use bits often, thereby have no need to memorize them.
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1111

Twenty seconds, mostly for typing.

Re: Hex signal view, hex and mathematical input in constants

Posted: Fri Jul 24, 2020 5:34 pm
by coppercoil
Opening the calculator is even faster. But why?

Re: Hex signal view, hex and mathematical input in constants

Posted: Fri Jul 24, 2020 6:26 pm
by Hannu
coppercoil wrote: Fri Jul 24, 2020 4:59 pm Can easily count bits - no. Most programmers don't use bits often, thereby have no need to memorize them.
You may be right. I began (hobby when I was a kid) at 80's and then everyone began learing binary and hexadecimal numbers on third day after getting first computer. I could disassemble 6510 code from hex dump on screen (not practical level, because I did not remember all rare instructions) and it was not unusual nerd skill on those days.

It may be better that I do not say my opinions of modern so called "programming languages" and so called "programmers". And especially their awful so called "commercial products" (I do not talk about Factorio now, it's quality is excellent). :)

Re: Hex signal view, hex and mathematical input in constants

Posted: Sat Jul 25, 2020 3:42 am
by ssilk
When I read over this, I thought it would be much more useful and easier to implement to have each number input field added two buttons:

Button 1 switches the displays of numbers: decimal, hex, binary and so on. By default always at dec. You can input numbers in dec/hex/bin and the mode switches automatically to that format. If you can do calculation inline here (see OP), it should display current result somewhere in the choosen format.

Button 2 opens a calculator window. How the calculator works is open, but for the first implementation it should have basic operators in decimals.

Re: Hex signal view, hex and mathematical input in constants

Posted: Sat Jul 25, 2020 8:17 pm
by Qon
ssilk wrote: Sat Jul 25, 2020 3:42 am How the calculator works is open, but for the first implementation it should have basic operators in decimals.
What is a decimal operator?

Re: Hex signal view, hex and mathematical input in constants

Posted: Sun Jul 26, 2020 2:30 am
by jamiechi1
I think unit conversions to various bases might be useful for some mods that provide a virtual processor that one can use in the game and write code for it. But in general, without mods, I don't see the need for it. Although if you add binary and hexadecimal, I want Octal conversions as well. :D