currently I am writing a program to convert one astronomical coordinate system into another one. The algorithms are written in a book I bought used, which is called "Practical Astronomy with your calculator".

In a certain step, the description says something like:
Depending on x and y being either positive or negative you have to add or to subtract
360 degree or 180 degree from h.
So there are four cases to destinquish:
+x +y
+x -y
-x -y
-x +y

Trying to avoid GTO (which is the most evil of all commands of all time...we know (...) I was trying
to find a small and neat solution which avoids unnecessary code executions.

I'd probably put a conditional check that puts either 1 or 2 on the stack, then another that puts either -1 or 1 on the stack (some rolling involved), then product of them and 180 aught to do it. Without the formula and conditions though it's hard to guess what you're trying to do