-- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department...

57
-- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via dei Gradenigo, 35131-IT Tel. +39-049-827-7833 mail: [email protected]

Transcript of -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department...

Page 1: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

-- Massimo Sartori, MSc (PhD Student)Intelligent Autonomous Systems Laboratory (IAS-LAb)Department of Information Engineering, University of PaduaVia dei Gradenigo, 35131-ITTel. +39-049-827-7833mail: [email protected]

Page 2: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Outline

• Integrazione Concetti di Java

• Notazioni Posizionali• Sistema Decimale• Sistema Binario• Cenni di Algebra Booleana• Sistema Esadecimale• Conversioni da base generica a base 10

• Conversioni da base 10 a base generica

• Rappresentazioni dei numeri nei calcolatori

• Rappresentazione di informazioni non numeriche nei calcolatori

Page 3: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Java Programming Language

public class BankAccount{

public BankAccount(){...}public void deposit(double amount){...}public withdraw(double amount){...}public double getBalance(){...}

public static void main(String[] args){.........

}}

Page 4: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Java Programming Language

• javac BankAccount.java BankAccountTester.java

• java BankAccountTester

public class BankAccount{

public BankAccount(){...}public void deposit(double amount){...}public withdraw(double amount){...}public double getBalance(){...}

}

public class BankAccountTester{public static void main(String[] args){

...BankAccount b = new .......

}}

Page 5: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Java Programming Language

• javac -cp BankAccountTester.java

• java BankAccountTester

public class BankAccount{

public BankAccount(){...}public void deposit(double amount){...}public withdraw(double amount){...}public double getBalance(){...}

}

Current Path

public class BankAccountTester{public static void main(String[] args){

...BankAccount b = new .......

}}

Page 6: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Java Programming Languagea%b

boolean operator, returns 0 or 1a%b == 1 if a is divisible by ba%b == 0 if a is NOT divisible by b

IEEEreminder(x,y)not a boolean operatorreturns the reminder of the division: x/yimport java.lang.Math;

Page 7: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Notazioni Posizionali

Page 8: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Sistema Numerico Binario• Sistema in base-2: rappresentazione di valori numerici usando 0 e 1

• Anche per rappresentare: Immagini, Suoni, Caratteri testuali, ecc.

• Usato in tutti i Computer e apparecchi elettronici

• Tutti i dati presenti su di un PC sono rappresentati in Binario

Page 9: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Sistema Numerico Decimale• Noi tutti conosciamo e utilizziamo il sistema numerico decimale (base-10) • Valori numerici rappresentati per mezzo di dieci “simboli”:

alfabeto = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

n, k ≥ 0

ia alfabetok210 1 2 1nn10 ....aaaaa....aaaN .

baseposizione

virgola

1236

2095.42 0.034

10234.666667

Page 10: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Notazione Posizionale in Base-10

kk

2-2

1-1

00

1n-1

2n-2

1n-1n

nn10

ba....baba

bababa....babaN

n, b ≥ 0 ia alfabeto

k210 1 2 1nn10 ....aaaaa....aaaN .

10

213

210 1 2 3

10 10

2095.420.020.45902000

1021045109102

102104105109100102

2095.42N

b = base-10

Page 11: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Notazione Posizionale in Base-2

n, b ≥ 0, ia alfabeto,

k210 1 2 1nn2 ....aaa.aa....aaaN

10

10 10 10101010

321

01234

22

27.625

0.1250.512816

212021

2121202121

11011.101N

base b = 2alfabeto = {0, 1}

bit

Conversione da Binario a Decimale

Page 12: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Sistema Numerico Binario: Perché?

• Importante perché tutti gli strumenti elettronici di nuova generazione rappresentano le informazioni sottoforma di numeri binari:

• Macchine fotografiche e telecamere digitali• PC• Console• Telefoni Cellulari• Ricevitori Satellitari Digitali• Televisioni Digitali (Plasma, LCD, HD)• Lettori Mp3

• Perché è più facile progettare un dispositivo elettronico capace di riconoscere solo due stati (0, 1) che dieci (0, 1, ... 9).

• Tali circuiti si chiamano Circuiti Digitali

• Un circuito digitale rappresenta • il bit 0 con un valore di tensione negativo (- 5V)• il bit 1 con un valore di tensione positivo (+ 5V)

Page 13: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Algebra Booleana

• I numeri binari sono stati resi “famosi” da George Boole (matematico britannico) che nel 1830 definì un’intera algebra basata su tali numeri detta Algebra Booleana.

• Tale algebra ha portato poi alla realizzazione di circuiti digitali e quindi all’evoluzione tecnologica attuale.

Aritmetica Binaria: A B A+B riporto AB A-B prestito 00 0 0 00 0 0 01 1 0 01 1 1 10 1 0 10 1 0 11 0 1 11 0 0

0101 x 01010000101 0000 010100000011001

0011001 : 0101 = 00101101 101 101 00101 101 101 000

Page 14: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

base b = 16

alfabeto = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}

• La notazione esadecimale consente di rappresentare le informazioni binarie in modo convenientemente compatto.

• Utilizzata per riferirsi alle locazioni di memoria di un calcolatore

Notazione Posizionale in Base-16

10

1- 0 1 2

16 16

1977.0625

1611691611167

7B9.1N

Conversione da Esadecimale a Decimale

Page 15: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

base b = 16

alfabeto = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}

• La notazione esadecimale consente di rappresentare le informazioni binarie in modo convenientemente compatto.

Notazione Posizionale in Base-16

216 16 0001 . 1001 1011 01117B9.1N 7 B 9 1

Page 16: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

• Perché raggruppamento di quattro bit?

Notazione Posizionale in Base-16

0 0

1 1

2 10

3 11

4 100

5 101 6 110 7 111

8 1000

9 1001

A 1010

B 1011

C 1100

D 1101

E 1110

F 1111

Page 17: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

base b = p

alfabeto = {0, 1, 2, ..., p-1}

• Conversione dalla base p alla base 10:

Notazione Posizionale in Base-p

k210 1 2 1nnp ....aaaaa....aaaN .

kk

2-2

1-1

00

11

22

1n-1n

nnp

pa....papa

bapapa....papaN

Page 18: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Conversioni da Base Decimale a Base p

Page 19: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Conversione di Interi da Base-10 a Base-p

Page 20: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Conversione del numero N=87 dalla base-10 alla base-2

6+1 = Numero di bit necessari per codificare N

bit 6 con rerapresenta posso che

Numeri di Numero 6422 6d

0 000000...63 111111

0/10/10/10/10/10/1

2222226264 numeri

Esempio di Conversione da Base-10 a Base-2

Page 21: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Conversione del numero N=87 dalla base-10 alla base-2

d+1 = Numero di bit necessari per codificare N

6422 6d

0 000000...63 111111

64 numeri

0 0000000.87 1010111.127 1111111

128 numeri

12822 71d

Esempio di Conversione da Base-10 a Base-2

Page 22: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Esempio di Conversione da Base-10 a Base-2

Conversione del numero N=87 dalla base-10 alla base-2

for i=0 to 6

i=0, N=87 1 87 mod 2 43 87 div 2

i=1, N=43 1 43 mod 2 21 43 div 2

i=2, N=21 1 21 mod 2 10 21 div 2

i=3, N=10 0 10 mod 2 5 10 div2

i=4, N=5 1 5 mod 2 2 5 div 2

i=5, N=2 0 2 mod 2 1 2 div 2

i=6, N=1 1 1 mod 2 0 1 div 2

210 101011187

Page 23: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Conversione di Frazionari da Base-10 a Base-p

Page 24: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Conversione di Frazionari da Base-10 a Base-p

kk

-22

-1110 pa....papaN

k21p ....aa0.aN alfabeto = {0, 1, 2, ..., p-1}i-a

Page 25: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Conversione di Frazionari da Base-10 a Base-p

kk

-22

-1110 pa....papaN

k21p ....aa0.aN

1) -(k k

1-21

kk

-22

-1110

pa....paa

p)pa....papa(pN

ParteIntera

ParteFrazionaria

1p 0.aN Parte da calcolare

Page 26: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Conversione di Frazionari da Base-10 a Base-p

kk

-22

-1110 pa....papaN

k21p ....aa0.aN

1) -(k k

1-21

kk

-22

-1110

pa....paa

p)pa....papa(pN

ParteIntera

ParteFrazionaria

1)-k(k

-1210 pa....paN

Page 27: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Esempio Conversione da Base-10 a Base-2

Conversione del numero N=0.625 dalla base-10 alla base-2

STOP 0N11.025.0a

0.5N00.5225.0a

0.25N11.252625.0a

3

2

1

Page 28: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione dei Numeri Interi nei Calcolatori

Page 29: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione dei Numeri Interi Relativi

• Le informazioni, numeriche o non, sono rappresentate in un elaboratore mediante elementi caratterizzati da una grandezza fisica (di solito di natura elettrica) che può assumere solo due valori (stati) che corrispondono alle cifre binarie 0 e 1.

• Si usa dire che ciascuno di questi elementi contiene un “bit”.

• Utilizzando sequenze di bit si possono rappresentare i numeri naturali (limitazioni dovute al numero finito di cifre).

• I numeri interi positivi in un calcolatore sono rappresentati con 16 o 32 bit.

1010

1010

1010

1010

1010

1010

1010

1010

1514

1312

1110

98

76

54

32

10

22

22

22

22

22

22

22

22

1111 1110

1101 1100

1011 1010

1001 1000

0111 0110

0101 0100

0011 0010

0001 0000

Corrispondeal tipo Int di Java

Page 30: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Interi Negativi: Rappresentazione in Ampiezza e Segno

• Metodo 1: Ampiezza e Segno

• Metodo 2: Complemento a Uno

• Metodo 3: Complemento a Due

Page 31: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Interi Negativi: Rappresentazione in Ampiezza e Segno

• Tale metodo utilizza il primo bit (quello più significativo) per indicare il segno.

• 0 segno +

• 1 segno -

1010

1010

1010

1010

1010

1010

1010

1010

77

66

55

44

33

22

11

00

22

22

22

22

22

22

22

22

1111 0111

1110 0110

1101 0101

1100 0100

1011 0011

1010 0010

1001 0001

1000 0000

Page 32: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Interi Negativi: Eccesso P

• Il numero relativo N rappresentato tramite la notazione binaria di N + P, dove • M = numero di bit usati nella rappresentazione

Esempio: M=4, P=8

1M2P

1010

1010

1010

1010

1010

1010

1010

1010

76

54

32

10

12

34

56

78

22

22

22

22

22

22

22

22

1111 1110

1101 1100

1011 1010

1001 1000

0111 0110

0101 0100

0011 0010

0001 0000

Page 33: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Interi Negativi: Complemento a uno

1010

1010

1010

1010

1010

1010

1010

1010

77

66

55

44

33

22

11

00

22

22

22

22

22

22

22

22

1000 0111

1001 0110

1010 0101

1011 0100

1100 0011

1101 0010

1110 0001

1111 0000

Page 34: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Interi Negativi: Complemento a due

• Metodo più diffuso

• La rappresentazione degli interi positivi corrisponde con quella dei primi numeri naturali

• Quella dei numeri negativi si ottiene aggiungendo una unità al complemento a uno.

1M2

Page 35: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Interi Negativi: Complemento a due

102

102

102

102

102

102

102

102

71000

61001

51010

41011

31100

21101

11110

01111

102

102

102

102

102

102

102

102

2222102

81000

71001

61010

51011

41100

31101

21110

11111

000010000)1(1111 01111

Complemento a uno

Complemento a due

Page 36: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Interi Negativi: Complemento a due

102

102

102

2

102

102

102

70111

60110

10001

00000

11111

71001

81000

Complemento a due

Svantaggi:

• dissimetria del numero negativo in più

Vantaggi:

• rappresentazione unica dello 0

• struttura ciclica: aggiungendo una unità al massimo numero rappresentabile (+7) si ootiene il minimo (-8)

• operazioni aritmetiche coi numeri negativi utilizzando le stesse regole dei numeri positivi considero negativi e positivi unitamente

Page 37: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Interi Negativi: Complemento a due

102

102

102

2

102

102

102

70111

60110

10001

00000

11111

71001

81000

Complemento a due Vantaggi:

• operazioni aritmetiche coi numeri negativi utilizzando le stesse regole dei numeri positivi considero negativi e positivi unitamente

7 01112 0010

5 0101

3 00112 1110

5 0101

1

Page 38: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Interi Negativi: Overflow nel Complemento a due

102

102

102

102

102

102

102

70111

60110

10001

00000

11111

71001

81000

Complemento a due • Il fenomeno di overflow (trasbordo) indica che il numero di bit a disposizione della rappresentazione non è sufficiente per rappresentare il risultato della somma corrente.si ha overflow se e solo se esiste un solo riportosulle due colonne più significative

9 10016 0110

3 0011

11 010116 1010

5 1011

7 100112 1110

5 1011

Overvlow Overvlow 1

Ok 11

Page 39: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione dei Numeri non Interi nei Calcolatori

Page 40: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione Fixed Point (Virgola Fissa)

• Viene definito: • il numero di bit per la rappresentazione (16 o 32)

• la posizione del punto che rimane fissa • parte intera algoritmo conversione da base 10 a base 2 di numeri interi • parte frazionaria algoritmo conversione da base 10 a base 2 di numeri interi

Page 41: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione Floating Point (Virgola Mobile)

• metodo di rappresentazione dei numeri razionali in base-2, • metodo di approssimazione dei numeri reali in base-2, • metodo utilizzato dai processori per compiere operazioni matematiche in base-2, • floating point posso specificare la posizione del pumto di separazione decimale mediante il valore di un esponente numero di cifre dopo la virgola non fisso. • notazione analoga alla notazione scientifica:

• Floating Point Unit deve essere presente all’interno del processore.

b e a dove ,10a b

Page 42: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione Floating Point (Virgola Mobile)

Vantaggi Floating Point rispetto a Fixed Point:

• può supportare un ampio numero di valori e quindi di dati

Esempio:

• Fixed Point con 7 cifre decimali e virgola dopo la quinta cifra:

00000.00 00034.00 12345.43 99999.99

• Floating Point con 7 cifre decimali

0.000001234567 0.000000 1.638956 127.7836 9999999.0 999999900000000.0

Svantaggi Floating Point rispetto a Fixed Point:

• c’è il bisogno di più spazio in memoria per memorizzare un numero floating point

Page 43: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione Floating Point nel Sistema Binario

• Nel sistema binario conviene usare come fattore di scala una potenza di due poiché in tal caso l’esponente indica direttamente il numero di posizioni di cui il punto binario va spostato:

Rappresentazione floating-point binaria del numero R (base-10):

1. Ricondurlo nella forma:

2. Rappresentare separatamente i due numeri M ed E in binario.

NOTA:• E (esponente o caratteristica) numero intero relativo

solitamente rappresentato secondo la convenzione eccesso-P,

• M (mantissa) numero razionale con una parte intera e una frazionaria rappresentato in virgola fissa e in ampiezza e segno

23

2 1011.0121.01101

EMR 2

Page 44: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione Floating Point (Virgola Mobile)

• Inizio anni 80 non esisteva una convenzione universale sul floating-point:

• Calcolatori IBM: E 7 bit riferito alla base b=16• Calcolatori DIGITAL: E 8 bit riferito alla base b=2

• 1985 Standard IEEE 754

mes

mantissaParte frazionaria di M

esponenteE=e-127

segno della mantissa ( 0= +, 1= - )

31 30 23 22 0

EbMR

Page 45: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione Floating Point (Virgola Mobile)

mes

mantissaParte frazionaria di M

esponenteE=e-127

segno della mantissa ( 0= +, 1= - )

31 30 23 22 0

EMR 2M: • virgola fissa col punto decimale implicitamente assunto alla destra del bit più significativo• normalizzata parte intera costituita da un unico bit pari a 1 (che non viene rappresentato)

•E:• assume valori tra -127 e +128• è riferito alla base 2

Page 46: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione Floating Point (Virgola Mobile)

0000000000000000000000001111010

Mantissa:hidden bit:1, tutti gli altri a 0

Esponente:-5 in notazione eccesso 127

Bit di segno: 0

31 30 23 22 0

100.031251. Ricondurlo nella forma:

2. Rappresentare separatamente i due numeri M ed E.

EMR 2 510 21.00.03125

mantissanormalizzata!!

Page 47: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione Floating Point (Virgola Mobile)

MantissaEsponente:in notazione eccesso 127

Bit di segno

11000011110100000000000000000000

1 10000111 10100000000000000000000

E = e-127 =

M =

S = 1 negativo

101010102 812713512710000111

102 625.000000000000001010000000 0.

108 4162625.12 EMR

Page 48: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Intervallo Floating Point (Virgola Mobile)

Qual è il numero con modulo più grande rappresentabile?

3812723

23

2323

1i

i02

22

104.32)2(2

:è abilerappresent grande più modulo con numero il Quindi

22M1

22221.1...1M1

cioè

1.1...1M1.0...0

Page 49: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Intervallo Floating Point (Virgola Mobile)

Qual è il numero con modulo più piccolo rappresentabile?

ATTENZIONE:

Overflow: Se il risultato di un’operazione è in modulo più grande del numero massimo rappresentabile

Underflow: Se il risultato di un operazione è compreso tra zero e il minimo numero rappresentabile

La distribuzione dei numeri rappresentabili non è uniforme; più densa vicino allo zero, rarefacendosi con l’aumentare del valore assoluto.

38126

23

108.121

:Quindi

22M1

Page 50: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Floating Point (Virgola Mobile)

Single Precision:

E: 8 bit (eccesso 127), M: 23 bit (normalizzata), S=1 bit 32 bit

Double Precision:

E: 11 bit (eccesso 1023), M: 52 bit (normalizzata), S=1 bit 64 bit

Quadruple Precision:

E: 15 bit (eccesso 32767), M: 112 bit (normalizzata), S=1 bit 128 bit

Page 51: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Floating Point (Virgola Mobile)

Single Precision:

E: 8 bit (eccesso 127), M: 23 bit (normalizzata), S=1 bit 32 bit

Double Precision:

E: 11 bit (eccesso 1023), M: 52 bit (normalizzata), S=1 bit 64 bit

Quadruple Precision:

E: 15 bit (eccesso 32767), M: 112 bit (normalizzata), S=1 bit 128 bit

Page 52: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione delle Informazioni non Numeriche

Page 53: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione delle Informazioni non Numeriche

• Anche le informazioni non numeriche vengono rappresentate per mezzo di bit• Avendo a disposizione N bit si possono rappresentare simboli diversi

Rappresentazione di Caratteri:

• Codice ASCII Standard Universalmente Utilizzato• Codifica a 7 bit codici:

• caratteri alfabeto maiuscoli e minuscoli, • cifre numeriche, • segni di interpunzione, • operatori aritmetici, • caratteri speciali ($,%,&,#, etc.)

• Codici ASCII memorizzati in supporti fisici (memorie, hard-disks) da 8 bit (byte) e occupano le 7 posizioni meno significative.• L’ottavo bit bit di parità• Trasmissione di informazioni introduzione di errori controllo in ricezione

N2

107 1282

Page 54: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione delle Informazioni non Numeriche

Codifica ASCII estesa:

• viene utilizzato un byte intero (8 bit)

• no bit di parità

• codici da 0 a 127 coincidono con la codifica non estesa

• caratteri da 128 a 255:

• variabili variamente accettate,• simboli altri alfabeti• alcuni simboli matematici,• simboli grafici

caratteri 25628

Page 55: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Rappresentazione delle Informazioni non Numeriche

Sistema di Acquisizione

5, 10, 16.33, 14.367, …

Campionamento di x(t)t

x(t)

Page 56: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Nota sulle Unità di Misura

Page 57: -- Massimo Sartori, MSc (PhD Student) Intelligent Autonomous Systems Laboratory (IAS-LAb) Department of Information Engineering, University of Padua Via.

Thank You

robotics.dei.unipd.it