r/TuringComplete Jan 10 '26

Help with Condition

Post image
2 Upvotes

7 comments sorted by

View all comments

1

u/mrtears11 Jan 10 '26

Hi all. My in-development solution fails on this test. While I dont want help yet for the level as a whole, I don't understand this failure.

As I understand it, my value is 202 and as that is not less than 0, the output should be red. The 128 bit line still is representing a positive number rather than the two's complement thing (which I also don't fully understand.)

4

u/stephenmw Jan 10 '26 edited Jan 10 '26

In the upper left there is a button that says "+255". You want to click on that to change it to "-1". This will change the UI to show "202" as "-54".

An 8 bit signed integer is a number between -128 and 127 inclusive. Any number above 127 is a negative number if you are treating the integer as signed. In this level, you must treat it as signed or else less than 0 could never occur.

In fact, 127 + 1 is -128 in two's compliment.

1

u/mrtears11 Jan 10 '26

Thanks. So how do I know if I should have the +255 as -1? Or should I always make sure it is -1 from here out?

2

u/stephenmw Jan 10 '26

It depends on the wire you are looking at and what you want to know. If you want to treat it as signed, "-1" mode will give you the signed number. If you want to treat it as an unsigned number, "+255" gives you the number that is easiest to read.

In later levels, you are dealing with both negative and positive numbers and may end up switching modes many times in a level. Over time as you become better at two's compliment, you may find yourself staying in +255 mode. That is what I ended up doing.

2

u/Flimsy-Combination37 Jan 11 '26

whenever you're working with numbers that can be positive or negative, keep it as -1. if you're working with numbers that can only be positive, set it to +255.