Das Open-Control-Projekt - Die Alternative zur C-Control-I


Das Forum zur C-Control-1
Welche C-Control-Varianten existieren?
Übersicht - Suchen - Neueste 50 Beiträge - Neuer Beitrag - Login - Registrieren
INFO - FAQ - CC2-Forum - CCPro-Forum 

 Re: Zahlenbereich Darstellung Kategorie: Verschiedenes (von H.J.W. - 27.10.2006 11:55)
 Als Antwort auf Re: Zahlenbereich Darstellung von Achim - 27.10.2006 2:34
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

Bisherige Antworten: