Page 1 of 1
Arithmetic Bitwise Operation Uses
Posted: Sun Aug 23, 2026 2:40 pm
by lp0Defenestrator
I'm currently teaching myself the various applications of the circuit network to do some more complex stuff in my builds. I found the bitwise operations for the arithmetic combinator. As a software developer, I think the inclusion of these is kind of awesome. However, I'm struggling with a practical application of what anyone would actually use them for. Can anyone share an example of where they are using these and to what purpose?
I'd also love to know why they were included in the first place if anyone has any idea about that.
Thank you for any help! This game is awesome.
Re: Arithmetic Bitwise Operation Uses
Posted: Sun Aug 23, 2026 5:38 pm
by Tertius
In game version 1.1 where it wasn't possible to use red+green as input separately in a combinator, it was helpful to set a mark on a value, to check if some value was marked and filter all marked values, and the ability to remove that mark again. This could be achieved by OR 0x8000000 - this sets the MSB. Checking for this mark was "if (value < 0) then ...", because marked values appear as negative due to integer arithmetic. Removing the mark to restore the original value was AND 0x7FFFFFF. However, this isn't much required any more.
In game version 2.x , I found just 1 useful application for bitwise operations so far. I built an interplanetary logistic system, where each planet advertises its planet specific items for pickup and trade to wherever they are requested. An advertisement is a signal with the item and value != 0. To use just 1 radar channel for all advertisements, Nauvis' advertisements all get value 1, Vulcanus' value 2, Gleba's value 4, Fulgora's value 8, Aquilo's value 16.
This way they could all be combined with OR but separated again by masking the corresponding bit(s). Whenever a planet wants an item, it can look up the advertisement channel and if the item it wants has a nonzero value, it knows it can request it from space and set the request in the cargo landing pad.
And whenever the hauler platform approaches a planet, it does (EACH on advertisement channel) AND (bit of the planet it approaches) to get a list of items to request from this planet. This way it's possible it requests advertised items from this planet and at the same time drop items requested by the planet down to the planet. On a different planet, you mask a different bit and get a different list of items to request and free to drop.
See
viewtopic.php?t=135362
However, the planet bitmapping is just a small part of the whole system.
I also created a cookbook for combinator concepts, may be you can take some inspiration from it. I'm currently in the process to include the new ELSE available in 2.1. It makes some builds smaller, for example a memory cell became possible with just 1 combinator in 2.1.
viewtopic.php?t=124776
Re: Arithmetic Bitwise Operation Uses
Posted: Sun Aug 23, 2026 6:30 pm
by mmmPI
you can use bit shifting for transmitting more data thru circuits, if you want to use the channel "iron ore" to transmit the quantity of iron ore from different outpost on the same wire the quantities will sum up, but you can use "only" the first 16 bits for one outpost and the next 16 bits for the second outpost's quantity, using [iron first outpost]<<16 + [iron second outpost] and similar combo of >> and << to decode
Same thing can also be used to encode signals for music notes for the speaker (
https://miditorio.com/ )
Re: Arithmetic Bitwise Operation Uses
Posted: Sun Aug 23, 2026 8:14 pm
by jdrexler75
I use them to detect different kinds of space station that are currently in orbit. Each station sends a "legendary light source" request with a different bit value as identifier, for instance the inner planet transporter is "4", the promethium ships that need eggs are "16" etc. I thought it was a little easier than making a bunch of different signals...
Re: Arithmetic Bitwise Operation Uses
Posted: Mon Aug 24, 2026 12:12 am
by lp0Defenestrator
Is this typically what this feature has been used for? There isn't much I can find about why these operands were added in the first place. I'm trying to figure out what problem it was trying to solve.
Re: Arithmetic Bitwise Operation Uses
Posted: Mon Aug 24, 2026 3:36 am
by zwickau
lp0Defenestrator wrote: Mon Aug 24, 2026 12:12 am
Is this typically what this feature has been used for? There isn't much I can find about why these operands were added in the first place. I'm trying to figure out what problem it was trying to solve.
Yes. I have only ever seen the bit shift operators used for bitpacking (I believe is the term); in this role, they suddenly become potentially very useful. I think their inclusion could also come down to the game's creators being very "technically-minded" people, if you know what I mean.
Re: Arithmetic Bitwise Operation Uses
Posted: Mon Aug 24, 2026 10:05 am
by Tertius
lp0Defenestrator wrote: Mon Aug 24, 2026 12:12 am
There isn't much I can find about why these operands were added in the first place. I'm trying to figure out what problem it was trying to solve.
If you look through the arithmetic combinator version history in the wiki, you see the bitwise operations were added with 0.15.0, in the early access phase. Previously, just the basic arithmetic operations were present. Modulo and power was also added in this update. No reason is given, however the context tells it's to provide a broader feature set. While bitwise is somewhat specific and not very common for people without programming background, modulo is essential.
It's a tool given to the players, with no intended or required use case. It's there just for the players to make use of it, whatever it may be.
Re: Arithmetic Bitwise Operation Uses
Posted: Mon Aug 24, 2026 1:19 pm
by worph
I have used them to set/read individual RGB values on lights more easily.
Re: Arithmetic Bitwise Operation Uses
Posted: Mon Aug 24, 2026 4:18 pm
by Alfonse215
Since 2.0 didn't have a way to communicate between a planet and a space platform, I use requests on a particular item (something that will never be satisfied) as a way to say that a platform is present around a planet. And I use a bitfield to be able to detect which platform it is.
This is mostly for biter egg handling. Each platform that requests eggs identifies itself with a specific bit; this allows multiple platforms to be identified. And I have spawners+rocket silo complexes tied to provide eggs for a specific platform's bit. A platform shows up, and its egg requests couple with its identifier. The silos that service that bit will load and launch eggs for it. Once the platform has its eggs, it leaves to use them (promethium haulers produce science when not at Nauvis so that it doesn't over-request eggs).
With 2.1, I don't need to use a bitfield; I can just dedicate some random virtual signal to be the universal egg requesting channel, and make silos look for particular signals instead of bits within a specific signal.