First, a word about the
-U flag. Internally, BitCycle only deals in 1's and 0's, so to allow working with decimal integers, it has flags to convert decimal input to unary. In particular,
-U allows for signed integers by adding a
0 to the front of any nonpositive integer's unary representation:
0. The same transformation is applied in reverse to the output, with the convenient addition that empty output is treated as
Try it online!
? gets the input, which goes straight into the
! to be output unchanged.
Try it online!
? gets the input. The
+ sends the leading
0 bit, if any, left (north), and the
1 bits right (south).
If there is a leading
0 bit, it hits the splitter
/ and turns east, deactivating the splitter. The
< sends it west again, through the deactivated splitter and off the playfield. The
0 bit that started on the playfield also hits the
< and goes through the deactivated splitter and off the playfield. Meanwhile, the
1 bits are directed around by the
^ and reach the
!, where they are output.
If there is no leading
0 bit, the
0 bit that starts on the playfield hits the
< and goes west to the splitter
/. Since the splitter has not been deactivated, it directs the bit south, and the
+ sends it west into the output
!. Meanwhile, the
1 bits are directed to the output, with enough delay to make sure they get there after the
TL;DR: Nonpositive inputs have their leading
0 bit stripped and their magnitude is output. Positive inputs have a leading
0 bit added and are thus output as negative numbers of the same magnitude.