Pages: 1
Posted on 09-13-11, 01:02 pm
Buster Beetle


Karma: 379
Posts: 263/464
Since: 06-29-11
What is a signed value? I notice with the moving stone blocks, it allows negative value entry. Or more like it converts negative numbers to a positive equivalent in hex. Is this what it does in this case? Does it give a value of 8 and 8, not 16 like normal?
Posted on 09-13-11, 06:27 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 850/4457
Since: 06-08-11
"Signed value" means that the value can have a sign. So it allows positive and negative numbers.

It uses the "Two's Complement" way of representing negative numbers which is standard in mostly all CPU's including the NDS. NSMB also uses it to represent negative numbers in the sprite data.

Basically, the idea is that the higher bit of the number (0x80 or 0x8) means that the number is negative. This cuts the number "in half" and every number greater or equal to 0x80 will be actually a negative number. It works this way:

(hex -> signed decimal)

0x7F -> 127
0x7E -> 126
..
02 -> 2
01 -> 1
00 -> 0
FF -> -1
FE -> -2
...
81 -> -127
80 -> -128
So a byte can either represent a number in the range 0 - 255 (unsigned) OR a number in the range -128 - 127 (signed).

(Same for single nybbles but they go from -8 to 7)
Pages: 1