Jump to content

GB Programming: Difference between revisions

→‎Negative numbers: Changed ALL the ranges, the dashes could be mistaken for minus signs.
>ISSOtm
(→‎Negative numbers: Changed the ranges, the dashes could be mistaken for minus signs.)
>ISSOtm
(→‎Negative numbers: Changed ALL the ranges, the dashes could be mistaken for minus signs.)
Line 418:
I've told you, "individual registers can hold unsigned 8-bit values, and pairs unsigned 16-bit values". However, these aren't true: these values can be signed. How does that work?
 
What we will be doing is cutting our number range in half, and telling one half is composed of negative numbers. But how to distinguish positive and negative numbers? Well, we tell the MSB is no longer meaning the symbol in front of 2^7, but it will give away the sign of the number (0 = positive, 1 = negative). So, instead of having values in ranges 0 -to 255 and 0 -to 65535, we will have values in ranges -128 to 127 and -32768 to 32767. Neat!
 
How to multiply by -1? Easy! You can either :
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.