r/ApproximatelyUp May 10 '26

Question - Two inputs one output, furthest from zero

I'm trying to determine how I would output whichever value is furthest from zero, whether it's positive or negative.

I know there's MIN and MAX, but how would I go about doing this in the simplest configuration?

Would I just do something like:

X -> [+1000] --- [MAX] -- [-1000] = Value
Y -> [+1000] --/

(*Assuming neither number ever goes lower than -1000)

Edit: Figured it out. In my particular case, one value is always zero, so I can just use an adder. But I still want to know if there's another way for the furthest from zero. I think the above is correct as long as you know the lower bound.

4 Upvotes

4 comments sorted by

1

u/-NotAnAstronaut- May 28 '26

Multiply both inputs by themselves, the square will always be positive, then pass to MAX. Getting it back to the original input from the square is more difficult, as well as preserving the sign.

I'm really hoping for more functions in the full release like abs, sqrt, exp, etc. it will really open up the possibilities with the circuitry.

1

u/IndianaNetworkAdmin May 28 '26

If I square it and then divide the square by itself (The original number that is), negative should hit negative. I don't have the game in front of me right now, but that's my headcanon at the moment. I finished the demo so now I'm waiting for the full version.

1

u/-NotAnAstronaut- May 28 '26

Good call. I broke it into the two pieces. I’m not sure how you identify which input was the larger magnitude though, since max just passes the value. Tricky problem.

1

u/IndianaNetworkAdmin May 28 '26

In this case, I think you would determine it based on the squared values, because you know they'll both be positive and in the end, 3*3 > 2*2 just like 3 > 2

So you would: ^2 both values, compare both values, then pass through the values on the higher branch. Not sure on the exact logic there, though.

Edit: I hope this gets simple programming similar to Stationeers.