|
|
(63 versioni intermedie di 2 utenti non mostrate) |
Riga 1: |
Riga 1: |
− | <div class=WordSection1>
| |
| | | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:14.5pt;
| + | '''Vitoantonio Bevilacqua''' [mailto:vitoantonio.bevilacqua@poliba.it vitoantonio.bevilacqua@poliba.it] |
− | margin-left:76.7pt'><b><span style='font-size:14.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>La codifica binaria della informazione</span></b><b><span
| + | |
− | style='font-size:8.0pt;line-height:107%;font-family:"Arial","sans-serif"'> </span></b><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
| | | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | ''Parole chiave:'' Codifica Binaria, Memoria RAM, Complemento a 2, IEEE 754 a singola e doppia precisione. |
− | margin-left:151.25pt;text-align:justify;text-justify:inter-ideograph;
| + | ==Introduzione == |
− | text-indent:-.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:
| + | Il fine principale degli argomenti trattati in queste iniziali lezioni consiste nell'illustrare in quale maniera l'informazione, per adesso soltanto numerica, viene memorizzata nella memoria RAM (Random Access Memory) di un sistema di calcolo rispettando standard condivisi, per poi essere elaborata attraverso un linguaggio di programmazione. In particolare si tratteranno: la codifica binaria, la codifica esadecimale, le conversioni di base, il concetto di errore di una codifica, la codifica di numeri interi con e senza segno in CA2 (complemento a 2), la codifica di numeri reali in singola e doppia precisione secondo lo standard IEEE 754, gli effetti sulla dichiarazione delle variabili signed e unsigned di tipo char ed int, e delle variabili float e double in linguaggio C. |
− | 107%;font-family:"Arial","sans-serif"'>Vitoantonio Bevilacqua </span></p>
| + | ==La memoria di lavoro == |
| + | La memoria RAM (Random Access Memory) è la memoria di lavoro (elaborazione) di un sistema di calcolo; per semplicità essa può essere rappresentata come una tabella organizzata in righe, ciascuna delle quali (per ora chiamata word) viene suddivisa in 4 colonne o blocchi, da ora in poi chiamati byte, costituiti da una sequenza di 8 bit (binary digit) ovvero 8 cifre che possono assumere soltanto valori 0 o 1. |
| + | In generale, ogni programma di elaborazione si occupa della gestione delle informazioni per unità elementari corrispondenti alla dimensione dei byte, senza necessariamente scendere al livello di dettaglio dei singoli bit, per questo motivo si dice che la unità minima indirizzabile (ovvero dotata di un indirizzo in memoria corrispondente alla posizione in memoria RAM) è il singolo byte. Il modo più diffuso di numerare i byte, iniziando sempre dal numero progressi 0, è da destra verso a sinistra (“little Endian”), laddove il verso dall’alto verso il basso è ovviamente relativo a come più avanti si dirà essere partizionata la intera memoria RAM. |
| + | ==Le regole per le trasformazioni di base == |
| + | Dato un numero, le basi del sistema di numerazione che si usano per leggere tale numero sono la base 2 (binaria), 8 (ottale), 16 (esadecimale); assegnata una base del sistema di numerazione, le cifre sono date da 0 fino a numero base – 1. Dopo la cifra 9, si aggiungono A, B, C, D, E, F per formare la base di un sistema esadecimale. |
| + | |
| + | Assegnato un numero codificato in base 2, si decodifica facilmente in base 10; esempio della codifica chiamata “in binario puro”: |
| + | |
| + | <span style='font-size:20px;'>[math](1010.101)_2 = (1 * 2^3+ 0 * 2^2+1 * 2^1+ 0 * 2^0 + 1 * 2^{-1}+ 0 * 2^{-2} + 1 * 2^{-3})_{10}=(10.625)_{10} [/math]</span> |
| + | |
| + | ''Codifica binaria di un numero:'' per l’operazione inversa, si utilizzano due algoritmi rispettivamente per la parte intera e decimale del numero: |
| + | |
| + | === Algoritmo di Horner - divisioni successive === |
| + | [[File:Passo 1.png|right]] |
| + | Si prende il numero intero, si mette in colonna a sinistra, lo si divide per 2, riportando quoziente sotto il dividendo mentre il resto accanto al dividendo, e così via fino a raggiungere il quoziente 0. La parte intera del numero in binario è la sequenza dei resti, presa dal basso verso l’alto. |
| + | |
| + | ===Algoritmo di Horner - moltiplicazioni successive === |
| + | [[File:passo2.png|right]] |
| + | Si prende il numero decimale, si mette in colonna a sinistra, lo si moltiplica per 2, riportando: |
| + | #Se il prodotto è ≥1, accanto al primo fattore 1 e sotto la parte decimale del prodotto |
| + | #Se il prodotto è <1, accanto al primo fattore lo 0 e sotto il prodotto |
| + | Cosi via, fino a raggiungere il prodotto 0. La sequenza da prendere come parte decimale del numero in binario è la sequenza di destra presa dall’alto verso il basso. |
| + | [[File:Passo3.png|right]] |
| + | Mentre nell’algoritmo delle divisioni lo 0 si raggiunge sempre, nell’algoritmo delle moltiplicazioni non è sempre possibile raggiungerlo e ciò dipende dal concetto di periodo della base; il periodo si ripete dal momento in cui si trova un numero già trovato in precedenza. |
| + | |
| + | '''Esempio: ''' |
| + | Codifica in binario e ricodifica in decimale del numero '''127.4''' |
| | | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:2.1pt;
| + | <span style='font-size:20px;'>[math](127.4)_{10} = (1111111.0110)_2 = (127.375)_{10} [/math]</span> |
− | margin-left:202.6pt'><span style='font-size:9.0pt;line-height:107%;font-family:
| + | |
− | "Arial","sans-serif"'> </span><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'> </span></p>
| + | |
| | | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:25.0pt; | + | Nel momento in cui si accetta un periodo, si commette un “errore di codifica”. Si definisce: |
− | margin-left:155.45pt'><u><span style='font-size:10.0pt;line-height:107%;
| + | *Errore assoluto lo scarto tra il numero iniziale da codificare e il numero ottenuto dopo la ricodifica nella stessa base di partenza. Esempio: [math]= 127.4 – 127.375 = 0.025[/math] |
− | font-family:"Arial","sans-serif"'>bevilacqua@poliba.it</span></u><span
| + | *Errore relativo <span style='font-size:20px;'>[math]e_r =\frac{e_a}{num}[/math]</span> dove ''num'' è il numero iniziale rispetto al quale si è commesso l’errore di codifica |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'> </span><b><span | + | Esempio: <span style='font-size:20px;'>[math]e_r = \frac{0.025}{127.4} [/math]</span> |
− | style='font-size:12.0pt;line-height:107%;font-family:"Arial","sans-serif"'> </span></b></p> | + | *Errore relativo percentuale <span style='font-size:20px;'>[math] e_{r\%} = e_r * 100 [/math]</span> |
| + | Concetto di ''range'' (intervallo di rappresentazione di un numero): preso un byte, supponendo che, avendo a disposizione n bit, tutti gli n codificano numeri interi in base binaria, il ''range'' di rappresentazione varia tra <span style='font-size:20px;'>[math][0, 2^n − 1][/math]</span> |
| | | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:93.6pt;margin-bottom:
| + | La formula deriva dal numero di combinazioni diverse che si possono ottenere |
− | 10.55pt;margin-left:35.8pt;text-indent:-1.0pt;line-height:104%'><b><span
| + | [math]2^n = 256[/math] Tenendo conto che si inizia la numerazione da 0. |
− | style='font-size:9.0pt;line-height:104%;font-family:"Arial","sans-serif"'>Sommario.</span></b><span
| + | Essendo 8 i bit: [0, 255] |
− | style='font-size:9.0pt;line-height:104%;font-family:"Arial","sans-serif"'> Il
| + | |
− | presente paragrafo si riferisce alle prime due lezioni del corso di Fondamenti
| + | |
− | di Informatica e Laboratorio di Informatica. </span><span style='font-size:
| + | |
− | 10.0pt;line-height:104%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
| | | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:93.6pt;margin-bottom:
| + | ===Codifica esadecimale di un numero=== |
− | 35.9pt;margin-left:35.8pt;text-indent:-1.0pt;line-height:104%'><b><span
| + | La codifica esadecimale di un numero è necessaria per rendere il codice più compresso (ovvero un numero inferiore di cifre). |
− | style='font-size:9.0pt;line-height:104%;font-family:"Arial","sans-serif"'>Parole
| + | Per eseguirla si possono utilizzare due metodi: |
− | chiave: </span></b><span style='font-size:9.0pt;line-height:104%;font-family:
| + | #Gli algoritmi da usare sono sempre gli algoritmi di Horner, con le opportune modifiche (in colonna si moltiplica e divide per 16). Infatti i due algoritmi sono generici, nel senso che, non dipendono dalla base in cui è rappresentato un numero. |
− | "Arial","sans-serif"'>Codifica Binaria, Memoria RAM, Complemento a 2, IEEE | + | #Si codifica in binario il numero, quindi, essendo [math]24 = 16[/math] si raccolgono le cifre a 4 a 4, a partire dalla virgola e si decodifica da base binaria a base decimale ciascuno dei blocchi Esempio: |
− | 754 a singola e doppia precisione. </span><span style='font-size:10.0pt;
| + | Codifica in esadecimale di [math] 65.25 : (65.25)_10 = (1000001.01)_2[/math] |
− | line-height:104%;font-family:"Arial","sans-serif"'> </span></p>
| + | {| class="wikitable" |
| + | |- |
| + | |0100 |
| + | |0001 |
| + | |.0100 |
| + | |- |
| + | |4 |
| + | |1 |
| + | |.4 |
| + | |} |
| | | |
− | <h1>1 Introduzione </h1>
| + | Dunque [math](65.25)_{10} = (41.4)_{16} [/math] |
| | | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:28.7pt;
| + | ===Rappresentazione con modulo e segno (“signed magnitude” o M&S)=== |
− | margin-left:8.3pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | Per rappresentare un numero con segno, si usa, per convenzione: |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | *Un bit per il segno: 0 per + (più), 1 per – (meno) |
− | font-family:"Arial","sans-serif"'>Il fine principale degli argomenti trattati
| + | *N-1 bit per il modulo |
− | in queste iniziali lezioni consiste nell'illustrare in quale maniera
| + | Il bit che codifica il segno è definito MSB (Most Significant Bit, il primo bit, il più significativo). |
− | l'informazione, per adesso soltanto numerica, viene memorizzata nella memoria
| + | Esempio:[math] n = 8[/math], range [math][-127,+127] [/math] |
− | RAM (Random Access Memory) di un sistema di calcolo rispettando standard
| + | [math](−11)_10 = (0011011)_2 [/math] |
− | condivisi, per poi essere elaborata attraverso un linguaggio di programmazione.
| + | [[File:Mantissa1.png|center]] |
− | In particolare si tratteranno: la codifica binaria, la codifica esadecimale, le
| + | In questo caso le combinazioni si riducono a 255 causa la doppia rappresentazione dello 0: [math]10000000 = 00000000 = 0[/math] e il range è: |
− | conversioni di base, il concetto di errore di una codifica, la codifica di
| + | <span style='font-size:20px;'>[math][-(2^{n-1}-1),2^{n-1}-1] = [-127,127]. [/math]</span> |
− | numeri interi con e senza segno in CA2 (complemento a 2), la codifica di numeri
| + | |
− | reali in singola e doppia precisione secondo lo standard IEEE 754, gli effetti
| + | ===L’operazione di complemento a uno. (CA1) === |
− | sulla dichiarazione delle variabili signed e unsigned di tipo char ed int, e
| + | E’ un’operazione molto semplice per un sistema di calcolo ed è alla base dell’operazione di complemento a due grazie alla quale è possibile rappresentare numeri interi negativi e positivi. |
− | delle variabili float e double in linguaggio C. </span></p>
| + | Per trovare la rappresentazione in complemento a uno si invertono semplicemente tutti i bit della parola. |
− | | + | |
− | <h1>2 La memoria di lavoro </h1>
| + | ===La codifica in complemento a due per i numeri con segno (CA2) === |
− | | + | Il complemento a due è il metodo più diffuso per la rappresentazione dei numeri con segno. Il valore da utilizzare relativamente al MSB risulta essere il suo opposto (questo implica che se vale 0 porta a una decodifica di valore uguale alla rappresentazione in binario puro): |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:7.85pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | :00000000=0 |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | :00000001=1 |
− | font-family:"Arial","sans-serif"'>La memoria RAM (Random Access Memory) è la
| + | :… |
− | memoria di lavoro (elaborazione) di un sistema di calcolo; per semplicità essa
| + | :01111111=+127 |
− | può essere rappresentata come una tabella organizzata in righe, ciascuna delle
| + | :10000000=-1⋅27=-128 |
− | quali (per ora chiamata word) viene suddivisa in 4 colonne o blocchi, da ora in
| + | :10000001=-128+1=-127 |
− | poi chiamati byte, costituiti da una sequenza di 8 bit (binary digit) ovvero 8
| + | :… |
− | cifre che possono assumere soltanto valori 0 o 1. </span></p>
| + | :11111111=-1 |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:1.8pt;
| + | Le combinazioni sono 256 per la rappresentazione univoca dello 0: ovvero soltanto [math]00000000 = 0[/math]; in questo caso il range varia tra [math][-(2^{n-1}),2^{n-1}-1] = [-128,127] [/math] . |
− | margin-left:7.85pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | Per codificare un numero in complemento a due: |
− | font-family:"Arial","sans-serif"'>In generale, ogni programma di elaborazione
| + | #Si sceglie il range per il quale è possibile codificare il numero e di conseguenza i bit necessari |
− | si occupa della gestione delle informazioni per unità elementari corrispondenti
| + | #Si rappresenta il valore assoluto del numero in binario |
− | alla dimensione dei byte, senza necessariamente scendere al livello di dettaglio
| + | #Si applica l’operazione di complemento a 1 e si somma 1 |
− | dei singoli bit, per questo motivo si dice che la unità minima indirizzabile
| + | #La sequenza ottenuta è la codifica del numero iniziale in complemento a due Esempio: |
− | (ovvero dotata di un indirizzo in memoria corrispondente alla posizione in
| + | Si vuole codifica in complemento a 2 il numero -65 |
− | memoria RAM) è il singolo byte. Il modo più diffuso di numerare i byte,
| + | :Il range varia tra [-128,127] |
− | iniziando sempre dal numero progressi 0, è da destra verso a sinistra (“little
| + | :[math]2^8[/math] combinazioni 𝑐𝑜𝑚𝑏𝑖𝑛𝑎𝑧𝑖𝑜𝑛𝑖 |
− | Endian”), laddove il verso dall’alto verso il basso è ovviamente relativo a
| + | :8 bit necessari |
− | come più avanti si dirà essere partizionata la intera memoria RAM. </span></p>
| + | :Il valore assoluto è: [math](65)_10 = (01000001)_2 [/math] |
− | | + | :Faccio il complemento a 1: [math]10111110 [/math] |
− | <h1 style='margin-left:.45pt'>3 Le regole per le trasformazioni di base </h1>
| + | :Il complemento a 2 è:[math] 10111110 + 1 = 10111111 [/math] |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | ==Lo standard IEEE 754 == |
− | margin-left:7.85pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | '''Standard IEEE 754 single precision: ''' |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | Rappresentazione di un numero reale in 32 bit. |
− | font-family:"Arial","sans-serif"'>Dato un numero, le basi del sistema di
| + | I 32 bit vengono suddivisi in 3 gruppi: |
− | numerazione che si usano per leggere tale numero sono la base 2 (binaria), 8
| + | {| class="wikitable" |
− | (ottale), 16 (esadecimale); assegnata una base del sistema di numerazione, le
| + | |- |
− | cifre sono date da 0 fino a numero base – 1. Dopo la cifra 9, si aggiungono A,
| + | |± |
− | B, C, D, E, F per formare la base di un sistema esadecimale. </span></p>
| + | |esponente |
− | | + | |mantissa |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.1pt;
| + | |- |
− | margin-left:7.8pt'><span style='font-size:10.0pt;line-height:107%;font-family:
| + | |1 |
− | "Arial","sans-serif"'> </span></p>
| + | |8 |
− | | + | |23 |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:1.4pt;
| + | |} |
− | margin-left:8.3pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | Il modulo del numero viene codificato in base binaria usando gli algoritmi di divisione e moltiplicazione successive evidenziando, nella parte decimale, un periodo ove ci fosse. |
− | font-family:"Arial","sans-serif"'>Assegnato un numero codificato in base 2, si
| + | La rappresentazione binaria risultante è detta “fixed point” (a virgola fissa). |
− | decodifica facilmente in base 10; esempio della codifica chiamata “in binario
| + | Si passa alla rappresentazione “floating point” (a virgola mobile) per determinare mantissa ed esponente. |
− | puro”: </span></p>
| + | Si sposta la virgola fino alla sinistra dell’ultima cifra diversa da zero, cambiando anche l’esponente per riequilibrare l’ordine di grandezza. |
− | | + | La parte dopo la virgola indica la mantissa matematica. |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | Se si sposta la virgola alla destra dell’ultima cifra diversa da zero, cambiando anche l’esponente: |
− | margin-left:7.8pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | *La parte del numero dopo la virgola indica la mantissa normalizzata che, se composta da un numero di cifre < 23, ai restanti bit si assegna valore 0 |
− | line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | *Per codificare l’esponente, si usa la rappresentazione per eccesso: si somma l’esponente al ''bias'' [math](2^{n−1} − 1)[/math] dove n è il numero di bit riservati all'esponente e quindi si codifica il numero |
− | | + | '''Esempio: ''' |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:5.7pt;
| + | Si vuole codificare secondo lo standard IEEE754 a single precision, il numero '''-118.625''' |
− | margin-left:7.85pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | *Codifico la parte intera: [math](118)_{10} = (1110110)_2[/math] |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | *Codifico la parte decimale: [math](0.625)_{10} = (.101)_2[/math] |
− | font-family:"Arial","sans-serif"'>(1010.101)<sub>2 </sub>= (1 x 2<sup>3</sup>+
| + | *La rappresentazione in fixed point è: '''1110110.101 ''' |
− | 0 x 2<sup>2</sup>+1 x 2<sup>1</sup>+ 0 x 2<sup>0 </sup>+ 1 x·2<sup>-1</sup>+
| + | *Sposto la virgola fino alla sinistra dell’ultima cifra diversa da 0 e riequilibrio l’ordine di grandezza: [math]0.1110110101*2^7[/math] |
− | 0 x 2<sup>-2 </sup>+ 1 x·2<sup>-3</sup>)<sub>10</sub>=(10.625)<sub>10</sub>
| + | *La mantissa matematica è: '''1110110101 ''' |
− | </span></p>
| + | *Sposto la virgola fino alla destra dell’ultima cifra diversa da zero e riequilibrio l’ordine di grandezza: [math]1.110110101*2^6[/math] |
− | | + | *La mantissa normalizzata è: '''110110101 ''' |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:3.95pt;
| + | *Codifico l’esponente: <span style='font-size:20px;'>[math]6 + 2^7 − 1 = 6 + 127 = 5 + 128 = 10000101 [/math]</span> |
− | margin-left:7.8pt'><span style='font-size:6.0pt;line-height:107%;font-family:
| + | *La rappresentazione secondo lo standard IEEE754 a single precision è: |
− | "Arial","sans-serif"'> </span><span style='font-size:10.0pt;line-height:107%;
| + | {| class="wikitable" |
− | font-family:"Arial","sans-serif"'> </span></p>
| + | |- |
− | | + | |1 |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |1000101 |
− | margin-left:8.3pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |11011010100000000000000 |
− | -.5pt;line-height:107%'><u><span style='font-size:10.0pt;line-height:107%;
| + | |- |
− | font-family:"Arial","sans-serif"'>Codifica binaria di un numero</span></u><span
| + | |± |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>:
| + | |esponente |
− | per l’operazione inversa, si utilizzano due algoritmi rispettivamente per la
| + | |mantissa |
− | parte intera e decimale del numero: </span></p>
| + | |} |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | L’ordine di precisione delo standard IEEE754 è dato dal numero di cifre della mantissa. |
− | margin-left:1.45pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | Per ottenere una rappresentazione più precisa si usa lo standard IEEE754 a double precision (64 bit) |
− | line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | {| class="wikitable" |
− | | + | |- |
− | <h2 style='margin-left:.45pt'>3.1 Algoritmo di Horner - divisioni successive <span
| + | |± |
− | style='font-weight:normal'> </span></h2>
| + | |esponente |
− | | + | |mantissa |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |- |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |1 |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |11 |
− | font-family:"Arial","sans-serif"'>Si prende il numero intero, si mette in
| + | |52 |
− | colonna a sinistra, lo si divide per 2, riportando quoziente sotto il dividendo
| + | |} |
− | mentre il resto accanto al dividendo, e così via fino a raggiungere il
| + | |
− | quoziente 0. La parte intera del numero in binario è la sequenza dei resti,
| + | Il metodo di rappresentazione è simile a quello usato per lo standard a single precision, l’unica cosa che varia è il bias: |
− | presa dal basso verso l’alto. </span></p>
| + | <span style='font-size:20px;'>[math]2^{11−1} − 1 = 1023 [/math]</span> |
− | | + | I valori assunti dall'esponente e dalla mantissa determinano l'appartenenza del numero ad una di queste categorie: |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | *Zeri; |
− | margin-left:18.75pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | *Numeri in forma normale; |
− | line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | *Numeri in forma denormalizzata; |
− | | + | *Infiniti; |
− | <h2 style='margin-left:.45pt'>3.2 Algoritmo di Horner - moltiplicazioni
| + | *NaN (not a number). |
− | successive <span style='font-weight:normal'> </span></h2>
| + | |
− | | + | {| class="wikitable" |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |- |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | ! Categoria |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | ! Esp. |
− | font-family:"Arial","sans-serif"'>Si prende il numero decimale, si mette in
| + | ! Mantissa |
− | colonna a sinistra, lo si moltiplica per 2, riportando: </span></p>
| + | |- |
− | | + | | Zeri |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | | 0 |
− | margin-left:58.1pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | | 0 |
− | -18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |- |
− | font-family:"Arial","sans-serif"'>1.<span style='font:7.0pt "Times New Roman"'>
| + | | Numeri denormalizzati |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>Se
| + | | 0 |
− | il prodotto è ≥1, accanto al primo fattore 1 e sotto il complemento del
| + | |non zero |
− | prodotto </span></p>
| + | |- |
− | | + | |Numeri normalizzati |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |1-254 |
− | margin-left:58.1pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |qualunque |
− | -18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |- |
− | font-family:"Arial","sans-serif"'>2.<span style='font:7.0pt "Times New Roman"'>
| + | |Infiniti |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>Se
| + | |255 |
− | il prodotto è <1, accanto al primo fattore lo 0 e sotto il prodotto </span></p>
| + | |0 |
− | | + | |- |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |Nan (not a number) |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |255 |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |non zero |
− | font-family:"Arial","sans-serif"'>Cosi via, fino a raggiungere il prodotto 0.
| + | |} |
− | La sequenza da prendere come parte decimale del numero in binario è la sequenza
| + | |
− | di destra presa dall’alto verso il basso. </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.15pt;
| + | |
− | margin-left:.7pt'><span style='font-size:10.0pt;line-height:107%;font-family:
| + | |
− | "Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:1.5pt;
| + | |
− | margin-left:.7pt'><span style='font-size:10.0pt;line-height:107%;font-family:
| + | |
− | "Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:74.95pt;margin-bottom:
| + | |
− | .25pt;margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-.5pt;line-height:107%'><img width=104 height=394
| + | |
− | src="1%20Prima%20Dispensa%20-La%20codifica%20binaria%20dell%20informazione_revisione2015_file/image001.gif"
| + | |
− | align=left hspace=12><span style='font-size:10.0pt;line-height:107%;font-family:
| + | |
− | "Arial","sans-serif"'>Mentre nell’algoritmo delle divisioni lo 0 si raggiunge
| + | |
− | sempre, nell’algoritmo delle moltiplicazioni non è sempre possibile
| + | |
− | raggiungerlo e ciò dipende dal concetto di periodo della base; il periodo si
| + | |
− | ripete dal momento in cui si trova un numero già trovato in precedenza. </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>Esempio: </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>Codifica in binario e ricodifica in decimale
| + | |
− | del numero 127.4 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:1.85pt;
| + | |
− | margin-left:99.3pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>(127.4)<sub>10 </sub>= (1111111.0110)<sub>2 </sub>=
| + | |
− | (127.375)<sub>10 </sub> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:124.9pt;margin-bottom:
| + | |
− | .25pt;margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:
| + | |
− | 107%;font-family:"Arial","sans-serif"'>Nel momento in cui si accetta un
| + | |
− | periodo, si commette un “errore di codifica”. Si definisce: </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:0cm;
| + | |
− | margin-left:37.45pt;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-18.0pt;line-height:112%'><span style='font-size:10.0pt;line-height:
| + | |
− | 112%;font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:112%;font-family:"Arial","sans-serif"'>Errore
| + | |
− | assoluto </span><span style='font-size:10.0pt;line-height:112%;font-family:
| + | |
− | "Cambria Math","serif"'>𝑒<sub>𝑎</sub></span><span
| + | |
− | style='font-size:10.0pt;line-height:112%;font-family:"Arial","sans-serif"'>lo
| + | |
− | scarto tra il numero iniziale da codificare e il numero ottenuto dopo la
| + | |
− | ricodifica nella stessa base di partenza. Esempio: </span><span
| + | |
− | style='font-size:10.0pt;line-height:112%;font-family:"Cambria Math","serif"'>𝑒<sub>𝑎</sub></span><span
| + | |
− | style='font-size:10.0pt;line-height:112%;font-family:"Arial","sans-serif"'>=
| + | |
− | 127.4 – 127.375 = 0.025 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:37.45pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>Errore
| + | |
− | relativo</span><img width=50 height=20 id="Picture 10409"
| + | |
− | src="1%20Prima%20Dispensa%20-La%20codifica%20binaria%20dell%20informazione_revisione2015_file/image002.gif"><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>dove
| + | |
− | <i>num </i>è il numero iniziale rispetto al quale si è commesso l’errore di
| + | |
− | codifica </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:37.95pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>Esempio: </span><img width=53 height=21
| + | |
− | id="Picture 10410"
| + | |
− | src="1%20Prima%20Dispensa%20-La%20codifica%20binaria%20dell%20informazione_revisione2015_file/image003.gif"><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:37.45pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>Errore
| + | |
− | relativo percentuale </span><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Cambria Math","serif"'>𝑒<sub>𝑟% </sub>= 𝑒<sub>𝑟
| + | |
− | </sub>∗ 100</span><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>Concetto di <i>range </i>(intervallo di
| + | |
− | rappresentazione di un numero): preso un byte, supponendo che, avendo a
| + | |
− | disposizione <i>n </i>bit, tutti gli <i>n </i>codificano numeri interi in base
| + | |
− | binaria, il <i>range </i>di rappresentazione varia tra </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal align=center style='margin-top:0cm;margin-right:0cm;
| + | |
− | margin-bottom:1.15pt;margin-left:2.55pt;text-align:center'><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Cambria Math","serif"'>[0,
| + | |
− | 2<sup>𝑛 </sup>− 1]</span><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Arial","sans-serif"'>. </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>La formula deriva dal numero di combinazioni
| + | |
− | diverse che si possono ottenere </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:176.75pt;margin-bottom:
| + | |
− | 1.9pt;margin-left:1.15pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:221.1pt;line-height:107%'><span style='font-size:10.0pt;line-height:
| + | |
− | 107%;font-family:"Cambria Math","serif"'>2<sup>𝑛 </sup>= 256</span><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>
| + | |
− | Tenendo conto che si inizia la numerazione da 0. </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>Essendo 8 i bit: [0, 255] </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.25pt;
| + | |
− | margin-left:.7pt'><span style='font-size:10.0pt;line-height:107%;font-family:
| + | |
− | "Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:18.5pt;margin-bottom:
| + | |
− | .25pt;margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-.5pt;line-height:107%'><u><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Arial","sans-serif"'>Codifica esadecimale di un
| + | |
− | numero</span></u><span style='font-size:10.0pt;line-height:107%;font-family:
| + | |
− | "Arial","sans-serif"'>: è necessaria per minimizzare il codice; per eseguirla
| + | |
− | si possono utilizzare due metodi: </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:58.85pt;margin-bottom:
| + | |
− | .25pt;margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:
| + | |
− | 107%;font-family:"Arial","sans-serif"'>1.<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>Gli
| + | |
− | algoritmi da usare sono sempre gli algoritmi di Horner, con le opportune
| + | |
− | modifiche (in colonna si moltiplica e divide per 16). Infatti i due algoritmi
| + | |
− | sono generici, nel senso che, non dipendono dalla base in cui è rappresentato
| + | |
− | un numero. </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:58.85pt;margin-bottom:
| + | |
− | .25pt;margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:
| + | |
− | 107%;font-family:"Arial","sans-serif"'>2.<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>Si
| + | |
− | codifica in binario il numero, quindi, essendo </span><span style='font-size:
| + | |
− | 10.0pt;line-height:107%;font-family:"Cambria Math","serif"'>2<sup>4 </sup>= 16 </span><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>si
| + | |
− | raccolgono le cifre a 4 a 4, a partire dalla virgola e si decodifica da base
| + | |
− | binaria a base decimale ciascuno dei blocchi Esempio: </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>Codifica in esadecimale di 65.25: (65.25)<sub>10
| + | |
− | </sub>= (1000001.01)<sub>2</sub>; </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-bottom:.25pt;line-height:107%'><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>0100
| + | |
− | 0001 .0100 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-bottom:.25pt;line-height:107%'><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>4 1
| + | |
− | .4 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>Dunque (65.25)<sub>10 </sub>= (41.4)<sub>16 </sub></span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:2.1pt;
| + | |
− | margin-left:.7pt'><span style='font-size:10.0pt;line-height:107%;font-family:
| + | |
− | "Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <h2 style='margin-left:.45pt'>3.3 Rappresentazione con modulo e segno (“signed
| + | |
− | magnitude” o M&S) </h2> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:3.55pt;
| + | |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>Per rappresentare un numero con segno, si
| + | |
− | usa, per convenzione: </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>Un
| + | |
− | bit per il segno: 0 per + (più), 1 per – (meno) </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:.25pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>N-1
| + | |
− | bit per il modulo </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:2.75pt;
| + | |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>Il bit che codifica il segno è definito MSB
| + | |
− | (Most Significant Bit, il primo bit, il più significativo). </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:5.15pt;
| + | |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>Esempio: n = 8, range [-127,+127] </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.15pt;
| + | |
− | margin-left:.95pt;text-indent:-.5pt'><span style='font-size:10.0pt;line-height:
| + | |
− | 107%;font-family:"Cambria Math","serif"'>(−11)<sub>10 </sub>= (0011011)<sub>2</sub></span><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal align=center style='margin-top:0cm;margin-right:0cm;
| + | |
− | margin-bottom:0cm;margin-left:3.35pt;margin-bottom:.0001pt;text-align:center'><img
| + | |
− | width=189 height=35 id="Picture 721"
| + | |
− | src="1%20Prima%20Dispensa%20-La%20codifica%20binaria%20dell%20informazione_revisione2015_file/image004.jpg"><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:77.0pt;margin-bottom:
| + | |
− | .25pt;margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-.5pt;line-height:107%'><span style='font-size:10.0pt;line-height:
| + | |
− | 107%;font-family:"Arial","sans-serif"'>In questo caso le combinazioni si
| + | |
− | riducono a 255 causa la doppia rappresentazione dello 0: 10000000 = 00000000 = | + | |
− | 0 e il range è: [-(2<sup>n-1</sup>-1),2<sup>n-1</sup>-1] = [-127,127]. </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:1.7pt;
| + | |
− | margin-left:.7pt'><span style='font-size:10.0pt;line-height:107%;font-family:
| + | |
− | "Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:78.65pt;margin-bottom:
| + | |
− | .25pt;margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-.5pt;line-height:142%'><b><span style='font-size:10.0pt;
| + | |
− | line-height:142%;font-family:"Times New Roman","serif"'>3.4 L’operazione di
| + | |
− | complemento a uno. (CA1) </span></b><span style='font-size:10.0pt;line-height: | + | |
− | 142%;font-family:"Arial","sans-serif"'>E’ un’operazione molto semplice per un
| + | |
− | sistema di calcolo ed è alla base dell’operazione di complemento a due grazie | + | |
− | alla quale è possibile rappresentare numeri interi negativi e positivi. </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:78.85pt;margin-bottom:
| + | |
− | .1pt;margin-left:0cm;line-height:101%'><span style='font-size:10.0pt;
| + | |
− | line-height:101%;font-family:"Arial","sans-serif";color:#252525'>Per trovare la
| + | |
− | rappresentazione in complemento a uno si invertono semplicemente tutti i bit | + | |
− | della parola. </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt'><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Times New Roman","serif"'>
| + | |
− | </span></p>
| + | |
− | | + | |
− | <h2 style='margin-left:.45pt'>3.5 La codifica in complemento a due per i numeri
| + | |
− | con segno (CA2) </h2> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:78.5pt;margin-bottom:
| + | |
− | .5pt;margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:
| + | |
− | 104%;font-family:"Arial","sans-serif"'>Il complemento a due è il metodo più
| + | |
− | diffuso per la rappresentazione dei numeri con segno. </span><span | + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>Il
| + | |
− | valore da utilizzare relativamente al MSB risulta essere il suo opposto (questo | + | |
− | implica che se vale 0 porta a una decodifica di valore uguale alla | + | |
− | rappresentazione in binario puro): </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:1.45pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>00000000=0 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:1.95pt;
| + | |
− | margin-left:36.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>00000001=1 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>… </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:4.1pt;
| + | |
− | margin-left:36.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>01111111=+127 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>10000000=-1</span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Segoe UI Symbol","sans-serif"'>⋅</span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>2<sup>7</sup>=-128
| + | |
− | </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:1.9pt;
| + | |
− | margin-left:36.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>10000001=-128+1=-127 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>… </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>11111111=-1 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:1.45pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:1.0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Le combinazioni sono 256 per la
| + | |
− | rappresentazione univoca dello 0: ovvero soltanto 00000000 = 0; in questo caso | + | |
− | il range varia tra [-(2<sup>n-1</sup>),2<sup>n-1</sup>-1] = [-128,127]. </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:12.15pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:2.55pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Per codificare un numero in complemento
| + | |
− | a due: </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:18.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | 18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>1.<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>Si
| + | |
− | sceglie il range per il quale è possibile codificare il numero e di conseguenza | + | |
− | i bit necessari </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:18.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | 18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>2.<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>Si
| + | |
− | rappresenta il valore assoluto del numero in binario </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:18.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | 18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>3.<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>Si
| + | |
− | applica l’operazione di complemento a 1 e si somma 1 </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:2.15pt;
| + | |
− | margin-left:18.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | 18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>4.<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>La
| + | |
− | sequenza ottenuta è la codifica del numero iniziale in complemento a due | + | |
− | Esempio: </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:2.3pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Si vuole codifica in complemento a 2 il
| + | |
− | numero -65 </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:3.65pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Il range varia tra [-128,127] </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:2.35pt;
| + | |
− | margin-left:.95pt;text-indent:-.5pt'><span style='font-size:10.0pt;line-height:
| + | |
− | 107%;font-family:"Cambria Math","serif"'>2<sup>8</sup> 𝑐𝑜𝑚𝑏𝑖𝑛𝑎𝑧𝑖𝑜𝑛𝑖</span><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Times New Roman","serif"'>
| + | |
− | </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:4.05pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>8 bit necessari </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:270.0pt;margin-bottom:
| + | |
− | .5pt;margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-.5pt;line-height:133%'><span style='font-size:10.0pt;line-height:
| + | |
− | 133%;font-family:"Times New Roman","serif"'>Il valore assoluto è: </span><span
| + | |
− | style='font-size:10.0pt;line-height:133%;font-family:"Cambria Math","serif"'>(65)<sub>10
| + | |
− | </sub>= (01000001)<sub>2</sub></span><span style='font-size:10.0pt;line-height:
| + | |
− | 133%;font-family:"Times New Roman","serif"'> Faccio il complemento a 1:
| + | |
− | 10111110 </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:2.3pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Il complemento a 2 è: 10111110 + 1 =
| + | |
− | 10111111 </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <h1 style='margin-left:.45pt'>4 Lo standard IEEE 754 </h1>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><u><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'>Standard IEEE 754
| + | |
− | single precision</span></u><span style='font-size:10.0pt;line-height:107%; | + | |
− | font-family:"Times New Roman","serif"'>: </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Rappresentazione di un numero reale in
| + | |
− | 32 bit. </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>I 32 bit vengono suddivisi in 3 gruppi: </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-bottom:.5pt;line-height:104%'><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>±
| + | |
− | esponente mantissa </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-bottom:.5pt;line-height:104%'><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>1
| + | |
− | 8 23 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Il modulo del numero viene codificato in
| + | |
− | base binaria usando gli algoritmi di divisione e moltiplicazione successive | + | |
− | evidenziando, nella parte decimale, un periodo ove ci fosse. </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>La rappresentazione binaria risultante è
| + | |
− | detta “fixed point” (a virgola fissa). </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Si passa alla rappresentazione “floating
| + | |
− | point” (a virgola mobile) per determinare mantissa ed esponente. </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Si sposta la virgola fino alla sinistra
| + | |
− | dell’ultima cifra diversa da zero, cambiando anche l’esponente per | + | |
− | riequilibrare l’ordine di grandezza. </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>La parte dopo la virgola indica la
| + | |
− | mantissa matematica. </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Se si sposta la virgola alla destra
| + | |
− | dell’ultima cifra diversa da zero, cambiando anche l’esponente: </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>La
| + | |
− | parte del numero dopo la virgola indica la mantissa normalizzata che, se | + | |
− | composta da un numero di cifre < 23, ai restanti bit si assegna valore 0 </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>Per
| + | |
− | codificare l’esponente, si usa la rappresentazione per eccesso: si somma | + | |
− | l’esponente al <i>bias </i>(</span><span style='font-size:10.0pt;line-height: | + | |
− | 104%;font-family:"Cambria Math","serif"'>2<sup>𝑛−1 </sup>−</span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.15pt;
| + | |
− | margin-left:37.25pt;text-indent:-.5pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Cambria Math","serif"'>1, 𝑑𝑜𝑣𝑒
| + | |
− | 𝑛 è 𝑖𝑙 𝑛𝑢𝑚𝑒𝑟𝑜
| + | |
− | 𝑑𝑖 𝑏𝑖𝑡 𝑟𝑖𝑠𝑒𝑟𝑣𝑎𝑡𝑖
| + | |
− | 𝑎𝑙𝑙′𝑒𝑠𝑝𝑜𝑛𝑒𝑛𝑡𝑒</span><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Times New Roman","serif"'>)
| + | |
− | e quindi si codifica il numero </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Esempio: </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:2.3pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Si vuole codificare secondo lo standard
| + | |
− | IEEE754 a single precision, il numero -118.625 </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>Codifico
| + | |
− | la parte intera: </span><span style='font-size:10.0pt;line-height:104%; | + | |
− | font-family:"Cambria Math","serif"'>(118)<sub>10 </sub>= (1110110)<sub>2</sub></span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>
| + | |
− | </span><span style='font-size:10.0pt;line-height:104%;font-family:"Segoe UI Symbol","sans-serif"'></span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Arial","sans-serif"'> </span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>Codifico
| + | |
− | la parte decimale: </span><span style='font-size:10.0pt;line-height:104%; | + | |
− | font-family:"Cambria Math","serif"'>(0.625)<sub>10 </sub>= (.101)<sub>2</sub></span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>
| + | |
− | </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>La
| + | |
− | rappresentazione in fixed point è: 1110110.101 </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>Sposto
| + | |
− | la virgola fino alla sinistra dell’ultima cifra diversa da 0 e riequilibrio l’ordine | + | |
− | di grandezza: </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:1.8pt;
| + | |
− | margin-left:37.25pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>0.1110110101*</span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Cambria Math","serif"'>2<sup>7</sup></span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>
| + | |
− | </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>La
| + | |
− | mantissa matematica è: 1110110101 </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>Sposto
| + | |
− | la virgola fino alla destra dell’ultima cifra diversa da zero e riequilibrio | + | |
− | l’ordine di grandezza: </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:1.95pt;
| + | |
− | margin-left:37.25pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>1.110110101*</span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Cambria Math","serif"'>2<sup>6</sup></span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>
| + | |
− | </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>La
| + | |
− | mantissa normalizzata è: 110110101 </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.15pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt'><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>•<span
| + | |
− | style='font:7.0pt "Times New Roman"'> </span></span><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Times New Roman","serif"'>Codifico
| + | |
− | l’esponente: </span><span style='font-size:10.0pt;line-height:107%;font-family: | + | |
− | "Cambria Math","serif"'>6 + 2<sup>7 </sup>− 1 = 6 + 127 = 5 + 128 =
| + | |
− | 10000101</span><span style='font-size:10.0pt;line-height:107%;font-family:"Times New Roman","serif"'> | + | |
− | </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>La
| + | |
− | rappresentazione secondo lo standard
| + | |
− | IEEE754 a single precision è:
| + | |
− | </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-bottom:.5pt;line-height:104%'> <span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>1
| + | |
− | 1000101 11011010100000000000000 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-bottom:.5pt;line-height:104%'> <span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>±
| + | |
− | esponente mantissa </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>L’ordine di precisione delo standard
| + | |
− | IEEE754 è dato dal numero di cifre della mantissa. </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Per ottenere una rappresentazione più
| + | |
− | precisa si usa lo standard IEEE754 a double precision (64 bit) </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-bottom:.5pt;line-height:104%'><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>±
| + | |
− | esponente mantissa </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-bottom:.5pt;line-height:104%'><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>1
| + | |
− | 11 52 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Il metodo di rappresentazione è simile a
| + | |
− | quello usato per lo standard a single precision, l’unica cosa che varia è il <i>bias: | + | |
− | </i></span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:13.3pt;
| + | |
− | margin-left:.95pt;text-indent:-.5pt'><span style='font-size:10.0pt;line-height:
| + | |
− | 107%;font-family:"Cambria Math","serif"'>2<sup>11−1 </sup>− 1 =
| + | |
− | 1023</span><span style='font-size:10.0pt;line-height:107%;font-family:"Times New Roman","serif"'> | + | |
− | </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:14.15pt;
| + | |
− | margin-left:1.65pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:147%'><span style='font-size:10.0pt;line-height:147%;
| + | |
− | font-family:"Arial","sans-serif"'>I valori assunti dall'esponente e dalla</span><a
| + | |
− | href="https://it.wikipedia.org/wiki/Mantissa"><span style='font-size:10.0pt;
| + | |
− | line-height:147%;font-family:"Arial","sans-serif";color:black;text-decoration:
| + | |
− | none'> </span></a><a href="https://it.wikipedia.org/wiki/Mantissa"><span
| + | |
− | style='font-size:10.0pt;line-height:147%;font-family:"Arial","sans-serif";
| + | |
− | color:black;text-decoration:none'>mantissa</span></a><a
| + | |
− | href="https://it.wikipedia.org/wiki/Mantissa"><span style='font-size:10.0pt;
| + | |
− | line-height:147%;font-family:"Arial","sans-serif";color:black;text-decoration:
| + | |
− | none'> </span></a><span style='font-size:10.0pt;line-height:147%;font-family:
| + | |
− | "Arial","sans-serif"'>determinano l'appartenenza del numero ad una di queste
| + | |
− | categorie: </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:4.2pt;
| + | |
− | margin-left:19.15pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>Zeri;
| + | |
− | </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:4.2pt;
| + | |
− | margin-left:19.15pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>Numeri
| + | |
− | in forma normale; </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:4.35pt;
| + | |
− | margin-left:19.15pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>Numeri
| + | |
− | in forma</span><a href="https://it.wikipedia.org/wiki/Numeri_denormalizzati"><span | + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif";
| + | |
− | color:black;text-decoration:none'> </span></a><a
| + | |
− | href="https://it.wikipedia.org/wiki/Numeri_denormalizzati"><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif";
| + | |
− | color:black;text-decoration:none'>denormalizzata</span></a><a
| + | |
− | href="https://it.wikipedia.org/wiki/Numeri_denormalizzati"><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif";
| + | |
− | color:black;text-decoration:none'>;</span></a><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:4.1pt;
| + | |
− | margin-left:19.15pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:107%'><span style='font-size:10.0pt;line-height:107%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>Infiniti;
| + | |
− | </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:4.8pt;margin-bottom:16.85pt;
| + | |
− | margin-left:19.15pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt'><span style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>•<span
| + | |
− | style='font:7.0pt "Times New Roman"'> </span></span><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Arial","sans-serif"'>NaN
| + | |
− | (<i>not a number</i>). </span></p> | + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:10.45pt;
| + | |
− | margin-left:.7pt'><span style='font-size:10.0pt;line-height:107%;font-family:
| + | |
− | "Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Arial","sans-serif"'> </span></p>
| + | |
− | | + | |
− | <table class=TableGrid border=0 cellspacing=0 cellpadding=0 width=428
| + | |
− | style='width:321.1pt;margin-left:81.25pt;border-collapse:collapse'> | + | |
− | <tr style='height:45.45pt'> | + | |
− | <td width=240 style='width:179.7pt;border:solid #AAAAAA 1.0pt;background:
| + | |
− | #F2F2F2;padding:0cm 5.75pt 13.85pt 4.8pt;height:45.45pt'>
| + | |
− | <p class=MsoNormal align=center style='margin-top:0cm;margin-right:0cm;
| + | |
− | margin-bottom:0cm;margin-left:.8pt;margin-bottom:.0001pt;text-align:center;
| + | |
− | line-height:normal'><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Categoria
| + | |
− | </span></b></p>
| + | |
− | </td>
| + | |
− | <td width=73 style='width:54.4pt;border:solid #AAAAAA 1.0pt;border-left:none;
| + | |
− | background:#F2F2F2;padding:0cm 5.75pt 13.85pt 4.8pt;height:45.45pt'>
| + | |
− | <p class=MsoNormal align=center style='margin-top:0cm;margin-right:0cm;
| + | |
− | margin-bottom:0cm;margin-left:.75pt;margin-bottom:.0001pt;text-align:center;
| + | |
− | line-height:normal'><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Esp.
| + | |
− | </span></b></p>
| + | |
− | </td>
| + | |
− | <td width=116 style='width:87.05pt;border:solid #AAAAAA 1.0pt;border-left:
| + | |
− | none;background:#F2F2F2;padding:0cm 5.75pt 13.85pt 4.8pt;height:45.45pt'>
| + | |
− | <p class=MsoNormal align=center style='margin-top:0cm;margin-right:0cm;
| + | |
− | margin-bottom:0cm;margin-left:.8pt;margin-bottom:.0001pt;text-align:center;
| + | |
− | line-height:normal'><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Mantissa
| + | |
− | </span></b></p>
| + | |
− | </td>
| + | |
− | </tr>
| + | |
− | <tr style='height:46.3pt'>
| + | |
− | <td width=240 valign=bottom style='width:179.7pt;border:solid #AAAAAA 1.0pt;
| + | |
− | border-top:none;background:#F2F2F2;padding:0cm 5.75pt 13.85pt 4.8pt;
| + | |
− | height:46.3pt'>
| + | |
− | <p class=MsoNormal align=center style='margin-top:0cm;margin-right:0cm;
| + | |
− | margin-bottom:0cm;margin-left:.65pt;margin-bottom:.0001pt;text-align:center;
| + | |
− | line-height:normal'><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Zeri
| + | |
− | </span></b></p>
| + | |
− | </td>
| + | |
− | <td width=73 valign=bottom style='width:54.4pt;border-top:none;border-left:
| + | |
− | none;border-bottom:solid #AAAAAA 1.0pt;border-right:solid #AAAAAA 1.0pt;
| + | |
− | background:#F9F9F9;padding:0cm 5.75pt 13.85pt 4.8pt;height:46.3pt'>
| + | |
− | <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
| + | |
− | normal'><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>0 </span></p>
| + | |
− | </td>
| + | |
− | <td width=116 valign=bottom style='width:87.05pt;border-top:none;border-left:
| + | |
− | none;border-bottom:solid #AAAAAA 1.0pt;border-right:solid #AAAAAA 1.0pt;
| + | |
− | background:#F9F9F9;padding:0cm 5.75pt 13.85pt 4.8pt;height:46.3pt'>
| + | |
− | <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
| + | |
− | normal'><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>0 </span></p>
| + | |
− | </td>
| + | |
− | </tr>
| + | |
− | <tr style='height:46.3pt'>
| + | |
− | <td width=240 valign=bottom style='width:179.7pt;border:solid #AAAAAA 1.0pt;
| + | |
− | border-top:none;background:#F2F2F2;padding:0cm 5.75pt 13.85pt 4.8pt;
| + | |
− | height:46.3pt'>
| + | |
− | <p class=MsoNormal align=center style='margin-top:0cm;margin-right:0cm;
| + | |
− | margin-bottom:0cm;margin-left:.65pt;margin-bottom:.0001pt;text-align:center;
| + | |
− | line-height:normal'><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Numeri
| + | |
− | denormalizzati </span></b></p>
| + | |
− | </td>
| + | |
− | <td width=73 valign=bottom style='width:54.4pt;border-top:none;border-left:
| + | |
− | none;border-bottom:solid #AAAAAA 1.0pt;border-right:solid #AAAAAA 1.0pt;
| + | |
− | background:#F9F9F9;padding:0cm 5.75pt 13.85pt 4.8pt;height:46.3pt'>
| + | |
− | <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
| + | |
− | normal'><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>0 </span></p>
| + | |
− | </td>
| + | |
− | <td width=116 valign=bottom style='width:87.05pt;border-top:none;border-left:
| + | |
− | none;border-bottom:solid #AAAAAA 1.0pt;border-right:solid #AAAAAA 1.0pt;
| + | |
− | background:#F9F9F9;padding:0cm 5.75pt 13.85pt 4.8pt;height:46.3pt'>
| + | |
− | <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
| + | |
− | normal'><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>non
| + | |
− | zero </span></p>
| + | |
− | </td>
| + | |
− | </tr>
| + | |
− | <tr style='height:46.35pt'>
| + | |
− | <td width=240 valign=bottom style='width:179.7pt;border:solid #AAAAAA 1.0pt;
| + | |
− | border-top:none;background:#F2F2F2;padding:0cm 5.75pt 13.85pt 4.8pt;
| + | |
− | height:46.35pt'>
| + | |
− | <p class=MsoNormal align=center style='margin-top:0cm;margin-right:0cm;
| + | |
− | margin-bottom:0cm;margin-left:.65pt;margin-bottom:.0001pt;text-align:center;
| + | |
− | line-height:normal'><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Numeri
| + | |
− | normalizzati </span></b></p>
| + | |
− | </td>
| + | |
− | <td width=73 valign=bottom style='width:54.4pt;border-top:none;border-left:
| + | |
− | none;border-bottom:double #F9F9F9 6.75pt;border-right:solid #AAAAAA 1.0pt;
| + | |
− | background:#F9F9F9;padding:0cm 5.75pt 13.85pt 4.8pt;height:46.35pt'>
| + | |
− | <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
| + | |
− | normal'><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>1-254
| + | |
− | </span></p>
| + | |
− | </td>
| + | |
− | <td width=116 valign=bottom style='width:87.05pt;border-top:none;border-left:
| + | |
− | none;border-bottom:double #F9F9F9 6.75pt;border-right:solid #AAAAAA 1.0pt;
| + | |
− | background:#F9F9F9;padding:0cm 5.75pt 13.85pt 4.8pt;height:46.35pt'>
| + | |
− | <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
| + | |
− | normal'><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>qualunque
| + | |
− | </span></p>
| + | |
− | </td>
| + | |
− | </tr>
| + | |
− | <tr style='height:46.45pt'>
| + | |
− | <td width=240 valign=bottom style='width:179.7pt;border:solid #AAAAAA 1.0pt;
| + | |
− | border-top:none;background:#F2F2F2;padding:0cm 5.75pt 13.85pt 4.8pt;
| + | |
− | height:46.45pt'>
| + | |
− | <p class=MsoNormal align=center style='margin-top:0cm;margin-right:0cm;
| + | |
− | margin-bottom:0cm;margin-left:.9pt;margin-bottom:.0001pt;text-align:center;
| + | |
− | line-height:normal'><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Infiniti
| + | |
− | </span></b></p>
| + | |
− | </td>
| + | |
− | <td width=73 valign=bottom style='width:54.4pt;border-top:none;border-left:
| + | |
− | none;border-bottom:solid #AAAAAA 1.0pt;border-right:solid #AAAAAA 1.0pt;
| + | |
− | background:#F9F9F9;padding:0cm 5.75pt 13.85pt 4.8pt;height:46.45pt'>
| + | |
− | <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
| + | |
− | normal'><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>255 </span></p>
| + | |
− | </td>
| + | |
− | <td width=116 valign=bottom style='width:87.05pt;border-top:none;border-left:
| + | |
− | none;border-bottom:solid #AAAAAA 1.0pt;border-right:solid #AAAAAA 1.0pt;
| + | |
− | background:#F9F9F9;padding:0cm 5.75pt 13.85pt 4.8pt;height:46.45pt'>
| + | |
− | <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
| + | |
− | normal'><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>0 </span></p>
| + | |
− | </td>
| + | |
− | </tr>
| + | |
− | <tr style='height:45.35pt'>
| + | |
− | <td width=240 valign=bottom style='width:179.7pt;border:solid #AAAAAA 1.0pt;
| + | |
− | border-top:none;background:#F2F2F2;padding:0cm 5.75pt 13.85pt 4.8pt;
| + | |
− | height:45.35pt'>
| + | |
− | <p class=MsoNormal align=center style='margin-top:0cm;margin-right:0cm;
| + | |
− | margin-bottom:0cm;margin-left:.6pt;margin-bottom:.0001pt;text-align:center;
| + | |
− | line-height:normal'><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Nan
| + | |
− | (not a number) </span></b></p>
| + | |
− | </td>
| + | |
− | <td width=73 valign=bottom style='width:54.4pt;border-top:none;border-left:
| + | |
− | none;border-bottom:solid #AAAAAA 1.0pt;border-right:solid #AAAAAA 1.0pt;
| + | |
− | background:#F9F9F9;padding:0cm 5.75pt 13.85pt 4.8pt;height:45.35pt'>
| + | |
− | <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
| + | |
− | normal'><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>255 </span></p>
| + | |
− | </td>
| + | |
− | <td width=116 valign=bottom style='width:87.05pt;border-top:none;border-left:
| + | |
− | none;border-bottom:solid #AAAAAA 1.0pt;border-right:solid #AAAAAA 1.0pt;
| + | |
− | background:#F9F9F9;padding:0cm 5.75pt 13.85pt 4.8pt;height:45.35pt'>
| + | |
− | <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
| + | |
− | normal'><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>non
| + | |
− | zero </span></p>
| + | |
− | </td>
| + | |
− | </tr>
| + | |
− | </table>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:1.8pt;
| + | |
− | margin-left:.7pt'><span style='font-size:10.0pt;line-height:107%;font-family:
| + | |
− | "Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <h1 style='margin-left:.45pt'>5 Verso il linguaggio C </h1>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:1.85pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Per specificare il tipo di variabile
| + | |
− | (tipo di rappresentazione usata per la codifica della variabile) esistono
| + | |
− | istruzioni dette </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:4.15pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>“specificatori di tipo”: </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>“char
| + | |
− | a”: carattere = variabile a memorizzata in 1 byte, codificata secondo C.A.2 </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>“int
| + | |
− | b”: intero = variabile b memorizzata in 2 o 4 byte (4 in VisualC++ 6.0),
| + | |
− | codificata secondo C.A.2 </span><span style='font-size:10.0pt;line-height:
| + | |
− | 104%;font-family:"Segoe UI Symbol","sans-serif"'></span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Arial","sans-serif"'> </span><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>“float
| + | |
− | c”: single = variabile c memorizzata in 4 byte, codificata secondo IEEE754
| + | |
− | single p. </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:36.75pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -18.0pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Arial","sans-serif"'>•<span style='font:7.0pt "Times New Roman"'>
| + | |
− | </span></span><span style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>“double
| + | |
− | d”: double = variabile d memorizzata in 8 byte, codificata secondo IEEE754
| + | |
− | double p. </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:2.0pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Non indicando niente davanti agli
| + | |
− | specificatori di tipo, si sottintende “signed”. Per specificare che la
| + | |
− | variabile è senza segno, si scrive “unsigned” davanti agli specificatori di
| + | |
− | tipo e la codifica avverrà senza segno. </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Per dimensionare una variabile, esistono
| + | |
− | gli specificatori “short” e “long” da scrivere davanti agli specificatori di
| + | |
− | tipo per, rispettivamente, dimezzare o raddoppiare il numero di byte necessari
| + | |
− | alla rappresentazione. </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:10.2pt;margin-bottom:
| + | |
− | 2.25pt;margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:
| + | |
− | 104%;font-family:"Times New Roman","serif"'>Per assegnare ad una variabile a il
| + | |
− | valore n si utilizza l’assegnazione “ a = n ; ” e, a seconda del tipo
| + | |
− | specificato di variabile, il calcolatore memorizzerà il valore n nel primo
| + | |
− | pacchetto libero di byte in modo che il primo byte sia multiplo di 4. </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:144.8pt;margin-bottom:
| + | |
− | .5pt;margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;
| + | |
− | text-indent:-.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:
| + | |
− | 104%;font-family:"Times New Roman","serif"'>L’indirizzo di una variabile “a” è
| + | |
− | indicato con “&a” ed è quindi multiplo di 4. N.B. la riga di codice a=a+1;
| + | |
− | non è un’uguaglianza, ma un’assegnazione! </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.5pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Il calcolatore all’indirizzo &a
| + | |
− | sovrascriverà al valore della variabile a, che quindi sarà perso, il valore
| + | |
− | incrementato di 1. </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:29.35pt;
| + | |
− | margin-left:1.2pt;text-align:justify;text-justify:inter-ideograph;text-indent:
| + | |
− | -.5pt;line-height:104%'><b><span style='font-size:10.0pt;line-height:104%;
| + | |
− | font-family:"Times New Roman","serif"'>Ringraziamenti.</span></b><span
| + | |
− | style='font-size:10.0pt;line-height:104%;font-family:"Times New Roman","serif"'>
| + | |
− | Il presente capitolo è stato scritto anche grazie al prezioso contributo dello
| + | |
− | studente Donato Mancuso con la successiva revisione del suo collega Pasquale
| + | |
− | Bonasia. </span></p>
| + | |
− | | + | |
− | <h1 style='margin-left:.45pt'>Riferimenti </h1>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.55pt;
| + | |
− | margin-left:36.0pt;text-indent:-18.0pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'>1.<span
| + | |
− | style='font:7.0pt "Times New Roman"'> </span></span><span
| + | |
− | style='font-size:9.0pt;line-height:107%;font-family:"Times New Roman","serif"'>Bevilacqua,
| + | |
− | V.: Dispense Teoria 1 e IEEE 754 In: http://www.vitoantoniobevilacqua.it </span><span
| + | |
− | style='font-size:10.0pt;line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.9pt;
| + | |
− | margin-left:36.0pt;text-indent:-18.0pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'>2.<span
| + | |
− | style='font:7.0pt "Times New Roman"'> </span></span><u><span
| + | |
− | style='font-size:9.0pt;line-height:107%;font-family:"Times New Roman","serif"'>http://it.wikipedia.org/wiki/IEEE_754</span></u><span
| + | |
− | style='font-size:9.0pt;line-height:107%;font-family:"Times New Roman","serif"'>
| + | |
− | </span><span style='font-size:10.0pt;line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.9pt;
| + | |
− | margin-left:36.0pt;text-indent:-18.0pt'><span style='font-size:10.0pt;
| + | |
− | line-height:107%;font-family:"Times New Roman","serif"'>3.<span
| + | |
− | style='font:7.0pt "Times New Roman"'> </span></span><u><span
| + | |
− | style='font-size:9.0pt;line-height:107%;font-family:"Times New Roman","serif"'>http://it.wikipedia.org/wiki/Ordine_dei_byte</span></u><span
| + | |
− | style='font-size:9.0pt;line-height:107%;font-family:"Times New Roman","serif"'>
| + | |
− | </span><span style='font-size:10.0pt;line-height:107%;font-family:"Times New Roman","serif"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:12.05pt;
| + | |
− | margin-left:.7pt'><b><span style='font-size:8.0pt;line-height:107%;font-family:
| + | |
− | "Times New Roman","serif"'>Appendice: Codice in linguaggio C (per ora solo di
| + | |
− | test) </span></b></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:76.9pt;margin-bottom:
| + | |
− | .15pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:navy'>#include</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'><stdio.h></span><span style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:76.9pt;margin-bottom:
| + | |
− | .15pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:navy'>#include</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'><conio.h></span><span style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:silver'> </span><span style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:green'>/*</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>non</span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:silver'> </span><span style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:green'>ANSI</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>C</span><span style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:silver'> </span><span style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:green'>*/</span><span style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:249.75pt;margin-bottom:
| + | |
− | .15pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>/*#include</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:green'><math.h></span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:green'>per</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>usare</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:silver'> </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>la</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:green'>funzione</span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:green'>pow*/</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New"'> </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:olive'>int</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>main() { </span><span lang=EN-US style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:olive'>unsigned</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:silver'> </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:olive'>char</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>byte[</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:navy'>4</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>];
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:silver'> </span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:olive'>unsigned</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:olive'>char</span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New"'>*c; </span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:silver'> </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:olive'>char</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>bit[</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:navy'>9</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>];
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:silver'> </span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:olive'>int</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>i,j; </span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:olive'>float</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:silver'> </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>a; </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:olive'>float</span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New"'>*p=NULL; </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:441.75pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>a=</span><span style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:navy'>0</span><span style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New"'>; </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:163.35pt;margin-bottom:
| + | |
− | .15pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>printf(</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>"Le</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>dimensioni</span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:silver'> </span><span style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:green'>in</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>byte</span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:silver'> </span><span style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:green'>di</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>variabili</span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:silver'> </span><span style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:green'>\n"</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>); </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>printf(</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>"char,</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>int,</span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:silver'> </span><span style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:green'>double</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>e</span><span style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:silver'> </span><span style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:green'>float</span><span style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>valgono</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>\n"</span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>); </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.15pt;
| + | |
− | margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>printf(</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>"%d</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:silver'> </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>%d</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:green'>%d</span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:green'>%d\n"</span><span lang=EN-US style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New"'>,</span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:olive'>sizeof</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>(</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:olive'>char</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New"'>),</span><span lang=EN-US style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:olive'>sizeof</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>(</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:olive'>int</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New"'>),</span><span lang=EN-US style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:olive'>sizeof</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>(</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:olive'>float</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New"'>),</span><span lang=EN-US style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:olive'>sizeof</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>(</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:olive'>double</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New"'>)); </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:451.35pt;margin-bottom:
| + | |
− | .15pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:olive'>do</span><span style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New"'> </span><span style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>{ </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:264.1pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>printf(</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>"inserisci</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>a</span><span style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:silver'> </span><span style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:green'>=</span><span style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>"</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>); </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>scanf(</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>"%f"</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>,&a); </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:76.9pt;margin-bottom:
| + | |
− | .15pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>/*a=(float)pow(2,</span><span style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:silver'> </span><span style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:green'>-2);utile</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>per</span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:silver'> </span><span style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:green'>trovare</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>il</span><span style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:silver'> </span><span style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:green'>range</span><span style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>di</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>rappresentazione*/</span><span style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New"'> </span><span style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>p=&a; </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.15pt;
| + | |
− | margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>c=(</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:olive'>unsigned</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:silver'> </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:olive'>char</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>*)p; </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:211.35pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New"'>printf(</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:green'>"%d</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New";color:green'>%d</span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:green'>%d</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>%d\n"</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New"'>,*(c+</span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:navy'>3</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>),*(c+</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:navy'>2</span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>),*(c+</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:navy'>1</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>),*c);
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:silver'> </span><span lang=EN-US style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New"'>printf(</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>"\n"</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New"'>); </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:olive'>for</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New"'>(i=</span><span lang=EN-US style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:navy'>0</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>;i<</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:navy'>4</span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>;i++) </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:264.1pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New"'>{ </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:316.9pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New"'>byte[i]=*(c+</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:navy'>3</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>-i);
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:silver'> </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>j=</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:navy'>0</span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>; </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:264.1pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:olive'>while</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>(byte[i]></span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:navy'>0</span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>) </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:264.1pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New"'>{ </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:312.15pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New"'>bit[j]=byte[i]%</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:navy'>2</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>;
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:silver'> </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>byte[i]=</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>byte[i]/</span><span lang=EN-US style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:navy'>2</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>;
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:silver'> </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>j=j+</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:navy'>1</span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>; </span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>}
| + | |
− | </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:264.1pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New";color:olive'>for</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New"'>(;j<</span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:navy'>8</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>;bit[j++]=</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:navy'>0</span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>); </span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:olive'>for</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New"'>(j=</span><span lang=EN-US style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:navy'>7</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>;j>=</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:navy'>0</span><span lang=EN-US style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>;j--) </span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>printf(</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>"%d"</span><span lang=EN-US style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New"'>,bit[j]); </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>printf(</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>"</span><span lang=EN-US style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:silver'> </span><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>"</span><span
| + | |
− | lang=EN-US style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>);
| + | |
− | </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:316.95pt;margin-bottom:
| + | |
− | .15pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span lang=EN-US
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>}
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:silver'> </span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>printf(</span><span style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:green'>"\n</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>\n"</span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>); </span><span style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>printf(</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:green'>"altro</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:green'>numero?\n"</span><span style='font-size:8.0pt;line-height:
| + | |
− | 103%;font-family:"Courier New"'>); </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:456.15pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'> </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>}
| + | |
− | </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:264.1pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:olive'>while</span><span style='font-size:8.0pt;line-height:103%;
| + | |
− | font-family:"Courier New"'>(getch()!=</span><span style='font-size:8.0pt;
| + | |
− | line-height:103%;font-family:"Courier New";color:green'>'n'</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>); </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;
| + | |
− | margin-left:.7pt;margin-bottom:.0001pt'><span style='font-size:8.0pt;
| + | |
− | line-height:107%;font-family:"Courier New"'> </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:0cm;margin-bottom:.15pt;
| + | |
− | margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span style='font-size:
| + | |
− | 8.0pt;line-height:103%;font-family:"Courier New";color:silver'> </span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:olive'>return</span><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New";color:silver'>
| + | |
− | </span><span style='font-size:8.0pt;line-height:103%;font-family:"Courier New";
| + | |
− | color:navy'>0</span><span style='font-size:8.0pt;line-height:103%;font-family:
| + | |
− | "Courier New"'>; </span></p>
| + | |
− | | + | |
− | <p class=MsoNormal style='margin-top:0cm;margin-right:264.1pt;margin-bottom:
| + | |
− | .2pt;margin-left:.45pt;text-indent:-.5pt;line-height:103%'><span
| + | |
− | style='font-size:8.0pt;line-height:103%;font-family:"Courier New"'>} </span></p>
| + | |
− | | + | |
− | </div>
| + | |
− | | + | |
− | </body>
| + | |
− | | + | |
− | </html>
| + | |
Il fine principale degli argomenti trattati in queste iniziali lezioni consiste nell'illustrare in quale maniera l'informazione, per adesso soltanto numerica, viene memorizzata nella memoria RAM (Random Access Memory) di un sistema di calcolo rispettando standard condivisi, per poi essere elaborata attraverso un linguaggio di programmazione. In particolare si tratteranno: la codifica binaria, la codifica esadecimale, le conversioni di base, il concetto di errore di una codifica, la codifica di numeri interi con e senza segno in CA2 (complemento a 2), la codifica di numeri reali in singola e doppia precisione secondo lo standard IEEE 754, gli effetti sulla dichiarazione delle variabili signed e unsigned di tipo char ed int, e delle variabili float e double in linguaggio C.
La memoria RAM (Random Access Memory) è la memoria di lavoro (elaborazione) di un sistema di calcolo; per semplicità essa può essere rappresentata come una tabella organizzata in righe, ciascuna delle quali (per ora chiamata word) viene suddivisa in 4 colonne o blocchi, da ora in poi chiamati byte, costituiti da una sequenza di 8 bit (binary digit) ovvero 8 cifre che possono assumere soltanto valori 0 o 1.
In generale, ogni programma di elaborazione si occupa della gestione delle informazioni per unità elementari corrispondenti alla dimensione dei byte, senza necessariamente scendere al livello di dettaglio dei singoli bit, per questo motivo si dice che la unità minima indirizzabile (ovvero dotata di un indirizzo in memoria corrispondente alla posizione in memoria RAM) è il singolo byte. Il modo più diffuso di numerare i byte, iniziando sempre dal numero progressi 0, è da destra verso a sinistra (“little Endian”), laddove il verso dall’alto verso il basso è ovviamente relativo a come più avanti si dirà essere partizionata la intera memoria RAM.
Dato un numero, le basi del sistema di numerazione che si usano per leggere tale numero sono la base 2 (binaria), 8 (ottale), 16 (esadecimale); assegnata una base del sistema di numerazione, le cifre sono date da 0 fino a numero base – 1. Dopo la cifra 9, si aggiungono A, B, C, D, E, F per formare la base di un sistema esadecimale.
Assegnato un numero codificato in base 2, si decodifica facilmente in base 10; esempio della codifica chiamata “in binario puro”:
Si prende il numero intero, si mette in colonna a sinistra, lo si divide per 2, riportando quoziente sotto il dividendo mentre il resto accanto al dividendo, e così via fino a raggiungere il quoziente 0. La parte intera del numero in binario è la sequenza dei resti, presa dal basso verso l’alto.
Si prende il numero decimale, si mette in colonna a sinistra, lo si moltiplica per 2, riportando:
Cosi via, fino a raggiungere il prodotto 0. La sequenza da prendere come parte decimale del numero in binario è la sequenza di destra presa dall’alto verso il basso.
Mentre nell’algoritmo delle divisioni lo 0 si raggiunge sempre, nell’algoritmo delle moltiplicazioni non è sempre possibile raggiungerlo e ciò dipende dal concetto di periodo della base; il periodo si ripete dal momento in cui si trova un numero già trovato in precedenza.
Nel momento in cui si accetta un periodo, si commette un “errore di codifica”. Si definisce:
La formula deriva dal numero di combinazioni diverse che si possono ottenere
[math]2^n = 256[/math] Tenendo conto che si inizia la numerazione da 0.
Essendo 8 i bit: [0, 255]
La codifica esadecimale di un numero è necessaria per rendere il codice più compresso (ovvero un numero inferiore di cifre).
Per eseguirla si possono utilizzare due metodi:
Il bit che codifica il segno è definito MSB (Most Significant Bit, il primo bit, il più significativo).
Esempio:[math] n = 8[/math], range [math][-127,+127] [/math]
[math](−11)_10 = (0011011)_2 [/math]
In questo caso le combinazioni si riducono a 255 causa la doppia rappresentazione dello 0: [math]10000000 = 00000000 = 0[/math] e il range è:
[math][-(2^{n-1}-1),2^{n-1}-1] = [-127,127]. [/math]
E’ un’operazione molto semplice per un sistema di calcolo ed è alla base dell’operazione di complemento a due grazie alla quale è possibile rappresentare numeri interi negativi e positivi.
Per trovare la rappresentazione in complemento a uno si invertono semplicemente tutti i bit della parola.
Il complemento a due è il metodo più diffuso per la rappresentazione dei numeri con segno. Il valore da utilizzare relativamente al MSB risulta essere il suo opposto (questo implica che se vale 0 porta a una decodifica di valore uguale alla rappresentazione in binario puro):
Le combinazioni sono 256 per la rappresentazione univoca dello 0: ovvero soltanto [math]00000000 = 0[/math]; in questo caso il range varia tra [math][-(2^{n-1}),2^{n-1}-1] = [-128,127] [/math] .
Il modulo del numero viene codificato in base binaria usando gli algoritmi di divisione e moltiplicazione successive evidenziando, nella parte decimale, un periodo ove ci fosse.
La rappresentazione binaria risultante è detta “fixed point” (a virgola fissa).
Si passa alla rappresentazione “floating point” (a virgola mobile) per determinare mantissa ed esponente.
Si sposta la virgola fino alla sinistra dell’ultima cifra diversa da zero, cambiando anche l’esponente per riequilibrare l’ordine di grandezza.
La parte dopo la virgola indica la mantissa matematica.
Se si sposta la virgola alla destra dell’ultima cifra diversa da zero, cambiando anche l’esponente:
L’ordine di precisione delo standard IEEE754 è dato dal numero di cifre della mantissa.
Per ottenere una rappresentazione più precisa si usa lo standard IEEE754 a double precision (64 bit)
Il metodo di rappresentazione è simile a quello usato per lo standard a single precision, l’unica cosa che varia è il bias:
[math]2^{11−1} − 1 = 1023 [/math]
I valori assunti dall'esponente e dalla mantissa determinano l'appartenenza del numero ad una di queste categorie: