
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
Hello, I thought we where talking about how to display a number like -32768? As you know: Hex Unsigned integers Signed intergers 0x0000 0 0 0x0001 1 1 .. .. 0x7ffe 32766 32766 0x7fff 32767 32767 0x8000 32768 -32768 0x8001 32769 -32767 0x8002 32770 -32766 .. .. 0xfffe 65534 -2 0xffff 65535 -1 Now remember its up to the programmers of the operating system if they want to implement signed integers. If the “sign bit” bit 16 is 1 then first a “-” is displayed. The hex value for -32768 is 0x8000. Invert 0x8000 and you get 0x7fff. 0x7fff is unsigned integer 32767. 0x7fff + 0x0001 = 0x8000 0x8000 is unsigned integer 32768 Display the unsigned integer 32768 And of course “-32768” is displayed. http://www.evergreen.edu/biophysics/technotes/program/2s_comp.htm#calculate http://www.rwc.uc.edu/koehler/comath/13.html Greetings, H.J.W. |
| Antwort schreiben |