56 lines
1.8 KiB
Markdown
56 lines
1.8 KiB
Markdown
|
|
# TD1
|
||
|
|
![[CI-EEA21EA5 - Elec_Num - CH1 - Système binaire - TD.pdf]]
|
||
|
|
|
||
|
|
## Execice SB1. Conversion
|
||
|
|
1.1 Conversion base 10 vers base B
|
||
|
|
1. $(10)_{10} = (?)_5$
|
||
|
|
$10 = 2\times5^1+0\times5^0\implies(10)_{10}=(20)_5$
|
||
|
|
2. $(5)_{10} = (?)_3$
|
||
|
|
$5 = 1\times3^1+2\times3^0\implies(5)_{10}=(12)_3$
|
||
|
|
3. $(123)_{10} = (?)_{16}$
|
||
|
|
$123=7\times16^1+11\times16^0\implies(123)_{10}=(7B)_{16}$
|
||
|
|
$(123)_{10}=(?)_2$
|
||
|
|
$123=1\times2^6+1\times2^5+1\times2^4+1\times2^3+0\times2^2+1\times2^1+1\times2^0$
|
||
|
|
$\implies(123)_{10}=(1111011)_2$
|
||
|
|
4. $(568)_{10}=(?)_{2}$
|
||
|
|
$568=1\times2^9+0\times2^8+0\times2^7+0\times2^6+1\times2^5+1\times2^4+1\times2^3+0\times2^2+0\times2^10\times2^0$
|
||
|
|
$\implies(568)_{10}=(1000111000)_{2}$
|
||
|
|
|
||
|
|
# Nombres positifs et négatifs
|
||
|
|
En binaire signé, le nombre 8 $(1000)_2$ devient $(01000)_{BS}$.
|
||
|
|
$(110000)_{BS}=-8$.
|
||
|
|
|
||
|
|
Pour $n$ bits + 1 bit de signe, on peut compter de de $-2^{n-1}$ à $2^{n-1}$.
|
||
|
|
|
||
|
|
Pb: Un nombre et son négatif ne s'additionnent pas à 0.
|
||
|
|
$(9)_{10} + (-9)_{10}=0$, mais $(01001)_2+(11001)_2=(00010)_2=(2)_{10}$
|
||
|
|
|
||
|
|
Complément à 2
|
||
|
|
2 méthodes:
|
||
|
|
1. Obtenir le complément à 1 puis ajouter 1.
|
||
|
|
Ex: C1 de $(0000 0010)_2\rightarrow(1111 1101)_2$
|
||
|
|
C2 =(C1 + 1) $\rightarrow(1111 1101)_2+(0000 0001)_2=(1111 1110)_2$
|
||
|
|
2. Conserver tous les bits à partir de la droite jusqu'au premier 1 inclus et inverser tous les bits suivants.
|
||
|
|
Ex: C2 de $(0000 0010)_2\rightarrow(\boxed{1111 11}10)_2$
|
||
|
|
|
||
|
|
## Exercice SB3:
|
||
|
|
2. Exprimer -12 sur 5 bits
|
||
|
|
$(-12)_{10}=(?)_{BS}$ sur 5 bits
|
||
|
|
$(12)_{10}=(01100)_{BS}$
|
||
|
|
C2 de $(01100)_{BS}$ = $(10100)_{BS}$
|
||
|
|
$(01100)_{BS}+(10100)_{BS}=(00000)_{BS}$
|
||
|
|
|
||
|
|
3.a)
|
||
|
|
$(33)_{10}=(?)_2$
|
||
|
|
$(33)_{10}=(100001)_2$ -> Il faut 6 bits
|
||
|
|
|
||
|
|
b)
|
||
|
|
$(100001)_2=(0100001)_{BS}$ -> Il faut 7 bits
|
||
|
|
|
||
|
|
c)
|
||
|
|
$(-33)_{10}=(?)_{BS}$
|
||
|
|
C2 de $(0100001)_{BS}$ -> $(1011111)_{BS}$
|
||
|
|
|
||
|
|
## Exercice SB4
|
||
|
|
$(568)_{10}$ = ($0101$ $0110$ $1000$)$_{DCB}$
|