Bit & Byte
Bit - (8, 16, 24, 32....) the minimum amount of information represented in the binary system. 1 or 0 symbolizes the status (on/off)
The game presents an example of one bit and it is a switch for electrical networks
Bytes are containers that store information from 1/0
8 bit = 1 byte
And to demonstrate the bit shift, I will use a 32-bit circuit
Below is a part of it, with white color indicating a byte and copper color indicating a bit
To confirm, here is the site[convertlive.com]
Binary And Decimal Numbers
How to get 13 in 1101? ¯\_(ツ)_/¯
To convert ordinary 13 to binary, use the division operation with the remainder
Thus, the binary representation of 13 is 1101
What does the "rule of converting a decimal number to binary" sound like?
When converting a decimal number to binary, you use the method of division by 2. If the number is divisible by 2, you write 0 (there is no remainder), and if the number is not divisible by 2, you write 1 (because we get the remainder). This rule is applied at each step of dividing a decimal number by 2 until the result is 0. After that, the remainders are written in reverse order to get the binary representation of the number.
An example based on game logic
Next, we'll use the online calculator, and this section is designed to help you understand the magic it creates
Most Significant Bit (MSB)
Sign bit. The leftmost bit in the number indicates the sign for a decimal number
For a 4-bit 1010, the most significant bit will be 1010, and for an 8-bit 1011 1011, respectively 1011 1011
For example, if I take 1 and shift it by 31, we will get the maximum negative value for 32-bit programs -2147483648
In the photo, none of the indicators are on, because the value is negative
However, if there is a 30-bit offset, the value will be 1073741824
Example of the MSB on a calculator
32 Bits
A Factorio is written in 32 bits
So, the representation of the maximum and minimum values for this bit depth is as follows
MIN -2 147 483 648 MAX 2 147 483 647
Feature:
If you add one to the maximum value, you get the minimum value
2 147 483 647
+1
-2 147 483 648
Similar to the minimum value
-2 147 483 648
-1
2 147 483 647
The reason for this is an overflow and this is what it sounds like
An overflow occurs when the result of an arithmetic operation goes beyond the possible range for a particular number format.
For example, in the binary representation of 32-bit numbers, if you add one to the maximum value, an overflow occurs, and the minimum value is obtained.
An example of overflow in life is the "tachometer"
When the maximum is reached, a new cycle begins
WarningIf you create a number of items close to the maximum value for 32 bits. The game may start to slow down and crash when it is overcrowded.
I can't give you a live example of this because I don't want to wait that long (>__<)
Bit Shift
Bit shift is the movement of bits in a binary number to the left or right. When a bit goes outside the number, it is lost, and new bits fill the empty spaces
I'll use a visual demonstration.
Let's take 13, which usually looks like this
Now let's shift left by 5
Moving by 5, we have 416 instead of 13
Although 1101 is also suitable for 13, 416 is simply found in a different place in the byte
By performing a bit shift, we ended up changing the decimal value on the output.
How it works in the game
https://youtu.be/fHAFPdr4fiU?si=L1X35fRtSTcCs2wt
The Scheme
In the constant combinator, data/values are set, then they get into the combinator that controls the bit shift: by the values 1,2,3..... and the direction to the right (>>) or left (<<)
Next, the signal goes to the arithmetic combinators, which in our case together play the role of 1 byte or 8 bits
From them, the signal goes to the combinator that divides by the remainder (%) *number* % 2
How Display Segments/signals Work
Take a display from the guide
https://steamcommunity.com/sharedfiles/filedetails/?id=3168628437
I will show you with the following example
Where 1 is a decimal representation and 2 is a bit representation
I take our symbol A into the combinator and shift it by 1
And we got a value with a plus sign.
Let me remind you that the condition for the display lamps to light up is the following "symbol" < 0
However, if you shift it by 2, the value will be minus because segment A should be lit on a two
My vision/explanation
The decimal value of a "symbol" is a bit code. It contains information about when the signal is positive and when it is negative. That is, thanks to it, small lamps know when they need to work and when not
Blueprint
Here is a 32-bit schematic and several ready-made display options
Install the "Text Plates"[mods.factorio.com] mod to see the characters
https://factoriobin.com/post/8iUNMTDm
Sources/Reference
OpenAI ChatGPT
Bit numbering
https://hmn.wiki/uk/Most_significant_bit
Bit
https://en.wikipedia.org/wiki/Bit
Sign bit
https://en.wikipedia.org/wiki/Sign_bit
Bit to byte
https://citizenmaths.com/ru/data-storage/32-bit-to-byte
Overflow
https://en.wikipedia.org/wiki/Integer_overflow
Bit shift
https://www.wikiwand.com/en/Bitwise_operation
https://www.wikiwand.com/uk/%D0%91%D1%96%D1%82%D0%BE%D0%B2%D0%B8%D0%B9_%D0%B7%D1%81%D1%83%D0%B2
Division with remainder
https://www.wikiwand.com/en/Euclidean_division
Factorio wiki
https://wiki.factorio.com/Arithmetic_combinator/uk
Most significant bit (MSB)
https://www.techtarget.com/whatis/definition/most-significant-bit-or-byte
https://youtu.be/KReHvV2SQj0?si=3UE24uqHKK_ONdYG
Scheme concept
https://youtu.be/KTdvGZfWMX4?si=iMD7NGpLYN9P_XW_
Source: https://steamcommunity.com/sharedfiles/filedetails/?id=3168668712
More Factorio guilds
- All Guilds
- Train builder for FACTORIO (ENG)
- 1188 (11 to 88 Flow Line Blueprints)
- Unpatched Bugs List as of Version 1.1.107
- Alternative Atmospherics
- Factorio Guide 842
- Haxard's Blueprint Book v1.1
- Achievements - Saved games
- Factorio
- 22 . Factorio | F
- FACTORIO (UA)