PDA

View Full Version : Problema Calcolo Somma In Complemento a 2 ad 8 bit


dengel_1
23-01-2010, 00:34
Ragazzi ho provato ad eseguire questo calcolo in complemento a 2 a 8 bit (quindi abbiamo (2^8-1) -1 = 127 numero massimo positivo esprimibile con 8 bit ( per nn ricadere nell'overflow) e -2^8= -128 per quanto riguarda il massimo negativo esprimibile..

La mia domanda è questa: se calcolo (+32-64) + 7 ---> al primo calcolo mi risulta

00100000 + 32 in binario
11000000 = -64 in complemento a 2
--------
11100000

Non dovrebbe essere -32 il risultato (non c'è overflow)?? il primo 1 sta per il segno negativo quindi risulta 1100000 ovvero 48 (32 + 16)...dove sbaglio?

Dumah Brazorf
23-01-2010, 01:23
http://it.wikipedia.org/wiki/Complemento_a_due

dengel_1
23-01-2010, 01:47
dove sbaglio?

Dumah Brazorf
23-01-2010, 11:42
Sbagli nel ricavare il numero negativo. Non è un semplice mettere a 1 il bit più significativo. 11100000 è proprio -32.

Hardware Upgrade Forum Database Error
Database Error Database error
The Hardware Upgrade Forum database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.hwupgrade.it home page, then try to open another page.
  • Click the Back button to try another link.
The www.hwupgrade.it forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.