Just curious if anyone know: where does the 127 come from for motors in RobotC (I don’t know what it is in other languages)? it seems 128 would fit better in binary/bits.
I believe that it’s 127 and not 128 because 0 also has to be registered in the 128 integer range.
I remember reading somewhere that it goes down to -128 as well.
That would make sense for an allowance on 256 integers.
So it comes from an 8 bit signed number
2^8 is 256 so 8 bit number can represent 256 numbers. This is usually allows (-128,127)
an unsigned byte can contain numbers 0 to 255 (totaling 256 states)
a signed byte can contain -128 to 127 (totaling 256 states)
negatives getting an extra number instead of positive is just a property of two’s compliment Two's complement - Wikipedia
Makes sense. Thanks everyone!