cours_progra/bac1/q2/fonctio/tp1/exercices.md

86 lines
1.3 KiB
Markdown
Raw Normal View History

2023-04-26 11:24:13 +02:00
# Exercices
## Binary
1) \\( \\)
2) 4095
3) 100000 (2) = 32 (10)
4) 000010 (2) = 2 (10)
5) 111111 (2) = 63 (10)
6) 010101 (2) = 21 (10)
7) 64 (10) = 0100 0000 (2)
8) 7 (10) = 0000 0100 (2)
9) 192 (10) = 1100 0000 (2)
10) 3073 (10) = 0110 0000 0001 (2)
11) 0x1010 = 4112
12) 0x10A0 = 4256
13) 0xBABE = 47806
14) 020 = 16
15) 072 = 58
16) sur papier = 0xCAFE
17) sur papier = 02001
18) 0xCAFE = 1100 1010 1111 1110
19) 0xCAFE = 0145376
20) 072 = 111010
21) > ./algo_q21.py
## Complement a 2
22)
23) \\( -2^11 → 2^11-1 \\)
24) 17 = 0001 0001
25) -17 = 1110 1101
26) 255 = 1111 1111 (Imposible car pas dans l'interval)
27) -128 = 1000 0000
28) -73 = 10110111
29) 01001111
+ 00000001
= 01010000
30) - 10010110 = 01101010
31) 01001111
+ 01000001
---------
= 10010000 (Overflow, le nombre n'est pas dans la range de nombre accesible sur 8 bits en ca2)
32) 00000001
- 00000010
----------
= 11111111
33) 00001001
x 00000110
----------
000010010
+ 0000100100
------------
= 0000110110
34) 10000001
- 10000010
----------
= 11111111
35) - 10000000 = 011111111 (Imposible a representer sur 8 bits)
36) 00010100
/ 00000101
----------
00000100
37) 00010111
/ 00001001
----------
00000010 (reste 101)
38)