Numeral System (Number System)
Numeral System (Number System)
INTRODUCTION:
Because of its electronic structure, the computer can only
assimilate two states, "0" and "1", which is why all the information it
circulates must be expressed in the binary system.
Exemple:
A CODING
(Binary) 0 1 0 0 0 0 0 1
• Types de Pure Binary code
codage
DCB (Binary Coded Decimal)
binary code
ASCII code.
Bar code
The QR code
13/02/2021 2
The first coding used by humans
Morse code
Invented in 1832 (Samuel
Morse) for telegraphy, this character
coding assigns a unique
combination of signals to each letter,
number and punctuation mark.
Morse code enables alphanumeric
text to be transmitted using a series
of short and long pulses. It is
considered the precursor of digital
communication.
Reminders on numbering systems
n n 1 1 0
N (b ) C n b C n 1 b ...... C1 b C 0 b
4
The decimal system (base 10)
The decimal system that we use, uses 10 symbols: 0, 1, 2, 3, 4, 5,
6, 7, 8 and 9. A number N is written with a succession of digits
representing the coefficients of powers of 10.
Example: N(10) = (2345)10
3 2 1 0
N(10) 2 * 10 3 * 10 4 * 10 5 * 10
The Binary System (base 2)
The base of this system is 2;
only 2 symbols are used: 0 or 1.
Example: A lamp is either on (1) or off (0).
Example :
Let the number N(8) = 1354, using the general method, be written
as :N(8) = (1354)8
The Hexadecimal System
(base 16)
The hexadecimal system uses 16 symbols: 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D,
E, F.
A(16) corresponds to 10(10), B(16) corresponds to 11(10), etc. (To keep a
single symbol, we have to go through the letters).
Example: Let the number N(16) = 6AF2 , using the general method, be
written as :
N(16) = (6AF2)16
Switching between bases
Change from base "b" to base "10":
let : ( N ) ( an an 1.......a1a0 ) b
( N )10 ( an b n an 1 b n 1 ...... a1 b1 a0 b 0 )
340 8
4 42 8
2 5 8 Therefore:(340)10=(524)8
5 0
Converting from base b1 to base b2
? b2
b1
Development
Successive
in polynomial
10 divisions
10
Fractional number representation
345 , 567
A fractional or
integer part decimal part
Example1
(1110) 2 1* 23 1* 2 2 1* 21 0 * 20 (14)10
(1110,101) 2 1* 23 1* 2 2 1* 21 0 * 20 1* 2 1 0 * 2 2 1* 2 3 (14,625)10
Fractional number representation
Example2
(127) 8 1* 82 2 * 81 7 * 80
(127,65) 8 1* 82 2 * 81 7 * 80 6 * 8 1 5 * 8 2
Example3
A real number is made up of two parts: the integer part and the
fractional part. The integer part is transformed by successive
divisions.The fractional part is transformed by successive
multiplication by 2 .
therfore 35,625=(100011,101)2
13
Example 2: (0,6)10=(?)2
0,6 * 2 = 1,2
0,2 * 2 = 0,4 (0,6)= (0,1001)2
0,4 * 2 = 0,8
0,8 * 2 = 1,6
Note :
The number of bits after the decimal point determines the precision.
14
Conversion : binaire octal
Binary Octal
. In octal, each base symbol is written on 3 bits
in binary. The basic idea is to replace each 000 0
symbol in the octal base by its value in 3-bit 001 1
binary ( make 3-bit bursts ). 010 2
Examples : 011 3
(345)8=(011 100 101)2 100 4
(65,76)8=(110 101, 111 110)2 101 5
110 6
(35,34)8=(011 101 , 011 100)2
111 7
15
Conversion : Octal binaire
The basic idea is to make 3-bit groupings starting from the least
significant bit Then replace each grouping by the corresponding
octal value.
Example :
16
Conversion : hexadécimal binaire
Hexadéci Décimal
mal
0 0
1 1
. In Hexa, each base symbol is written on 4 bits. The 2 2
basic idea is to replace each symbol by its value in 3 3
binary on 4 bits ( make on 4 bits). 4 4
5 5
6 6
7 7
Example :
8 8
(345B)16=(0011 0100 0101 1011)2
9 9
(AB3,4F6)16 = ( 1010 1011 0011 , 0100 1111 0110 ) 2 A 10
B 11
C 12
D 13
E 14
F 15
17
Conversion : binaire hexadécimal
. The basic idea is to make 4-bit groupings starting from the least significant bit.
Then replace each grouping with the corresponding Hexa value.
Example :
(11001010100110)2=(0011 0010 1010 0110)2=(32A6)16
(110010100,10101)2= (0001 1001 0100,1010 1000)2=(194,A8)16
18
Exercice
(45,76)8 =(?)10
(123)6=(?)10
(1100,11)2 =(?)10
(1ABC)16 =(?)10
19
Binary arithmetic operations
Subtraction
Addition
- 0 1
+ 0 1
0 0 1(1)
0 0 1
1 1 0(1) 1 1 0
a) 11011 +10011=101110
b) 1110-1001=101
Multiplication Division
/ 0 1
* 0 1
0 ND 0
0 0 0
1 0 1
1 ND 1
c) 1101*101=1000001
d) 1001 / 11=11
Opérations arithmétiques en octal
1 1
4 3 6 5
+
4 5 1
5 8 11 6
0 3
21
Hexadecimal arithmetic operations
4 8 6 5
+
7 A 5 1
12 18 11 6
C IN hexa 11 s’écrit B
IN hexa 18 s’écrit 12
B
2
22
Exercice
Perform the following operations and convert the result to
a decimal each time:(1101,111)2+(11,1)2=(10001,011)2
(43)8+(34)8=(77)8
(43)6+(34)6=(121)6
(AB1)16+(237)8=(B50)16
23
Types of coding in computer science
Code ASCII:
ASCII code (American Standard Code for Information Interchange). A complete
and acceptable character set must contain at least :
all 26 Capital letter,
26 Minuscule letter,
ten digits,
approximately 25 special characters such as +, -, #, %, ...etc.
5. Le code Barre
This marking consists of a number of
vertical bars and 13 numbers. The first
number indicates the country of origin,
the next 5 are the manufacturer's code, the
next 6 are the article code, and the 13th is
a control key.
QR codes and images,
6,Code QR :
QR" stands for Quick Response. The QR
code can contain a lot of information: 7089 numeric
characters, 4296 alphanumeric characters, as opposed
to the 10 to 13 character barcode or 2953 bytes. The
QR code can contain text, a telephone number, an
SMS, a website address, an e-mail address...etc.
7. Image coding
Images are made up of an L x H (Width x Height) matrix of elementary points,
generally referred to as pixels (short for Picture Element). Each pixel has a color
coded on a greater or lesser number of bits. The output device (screen, printer,
etc.) must render the pixels in an orderly fashion according to their respective
position (x, y) and color.
Image coding
Image with 256 colors 1 byte (8 bits) for each pixel True
color image 16 million colors 3 bytes (24 bits) for each pixe