Documente Academic
Documente Profesional
Documente Cultură
Meditații Info - Prezentare 2
Meditații Info - Prezentare 2
https://docs.google.com/document/d/1iLf2eZlNYOkhbh
r2pWT0ARRBxNvPlgctmAXmtT8RdmA/edit?usp=sharing
Coversia din Baza 10 în Baza 2
11 Câtul Restul Rezultat:
11 / 2 5 1 (11)10 = ( 1 0 1 1 )2
5/2 2 1
2/2 1 0
1/2 0 1
Exemple:
( 1000011 ) 2 = 1 + 2 + 26 = 3 + 64 = 67
(0110)2 = 6 17 = 10001 7 = 0111
(0110 0010)2 = 2 + 32 + 64 = 98
(1111 1111) 2 = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 = 255
= 2^0 + 2^1 + 2^2 + … + 2^7 = (2^8 – 1) / (2 - 1) = 255
q + q^2 + q^3 + … q^n = (q^(n+1) - 1) / (q - 1)
Cum reprezentăm numerele negative?
Sign Magnitude One’s Complement
1111 -7 1000 -7
1110 -6 1001 -6
1101 -5 1010 -5
1100 -4 1011 -4
1011 -3 1100 -3
1010 -2 1101 -2
1001 -1 1110 -1
1000 -0 1111 -0
0000 +0 0000 +0
0001 1 0001 1
0010 2 0010 2
0011 3 0011 3
0100 4 0100 4
0101 5 0101 5
0110 6 0110 6
0111 7 0111 7
Cum reprezentăm numerele negative?
Two’s Complement
-8 4 2 1
1000 -8 One’s complement – pur și simplu
1001 -7
1010 -6
se inversează biții
1011 -5
1100 -4
1101 -3 Two’s complement – se adaugă +1
1110 -2
1111 -1
la one’s complement
0000 0
0001 1
0010 2 Numerele negative se stochează în
0011 3
0100 4
memoria calculatorului sub forma
0101 5 de Two’s Complement
0110 6
0111 7
Tipuri de date (built-in)
D A TA T Y P E SIZE (in bytes) RANGE
char 1 -128 to 127
unsigned char 1 0 to 255
int 4 -2,147,483,648 to 2,147,483,647
unsigned int 4 0 to 4,294,967,295
short int 2 -32,768 to 32,767
long long 8 -(263) to (263)-1
unsigned long long 8 0 to 18,446,744,073,709,551,615
float 4
double 8
1000 0000 = - 2^7 = -128 0111 1111 = 2^7 – 1 = 127 0000 0000; 1111 1111 = 2^8 – 1= 256 – 1 = 255
Int main()
{
int a = 0; for (…) { int c; }
int b;
}
Operatori
Enum
Temă