0% found this document useful (0 votes)
45 views24 pages

Understanding Number Systems in Mathematics

The document discusses different number systems including decimal, binary, octal, and hexadecimal. It explains how to convert between these number systems using methods like successive division and weighted multiplication. Examples are provided to demonstrate converting between octal and binary and between hexadecimal and octal.

Uploaded by

Sudipto Ghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views24 pages

Understanding Number Systems in Mathematics

The document discusses different number systems including decimal, binary, octal, and hexadecimal. It explains how to convert between these number systems using methods like successive division and weighted multiplication. Examples are provided to demonstrate converting between octal and binary and between hexadecimal and octal.

Uploaded by

Sudipto Ghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Discrete Mathematics

Presented By
Md. Ashiqur Rahman
Assistant Professor
Department of CSE,BUBT

2
What Digit? => Number
System
• Famous Number System: Dec, Rom, Bin
• Decimal System: 0 ‐9
– May evolves: because human have 10 finger
• Roman System
– May evolves to make easy to look and feel
– Pre/Post Concept: (IV, V & VI) is (5‐1, 5
& 5+1)
• Binary System, Others (Oct, Hex)

3
Significant Digits
Binary: 11101101

Most significant digit Least significant digit

Decimal: 1063079

Most significant digit Least significant digit


Decimal (base 10)

• Uses positional representation


• Each digit corresponds to a power of 10 based
on its position in the number
• The powers of 10 increment from 0, 1, 2, etc.
as you move right to left
– 1,479 = 1 * 103 + 4 * 102 + 7 * 101 + 9 * 100
Binary (base 2)

• Two digits: 0, 1
• To make the binary numbers more
readable, the digits are often put in groups
of 4
– 1010 = 1 * 23 + 0 * 22 + 1 * 21 + 0 * 20
=8+2
= 10
– 1100 1001 = 1 * 27 + 1 * 26 + 1 * 23 + 1 * 20
= 128 + 64 + 8 + 1
= 201
How to Encode Numbers: Binary
Numbers
• Working with binary numbers
– In base ten, helps to know powers of 10
• one, ten, hundred, thousand, ten thousand, ...
– In base two, helps to know powers of 2
• one, two, four, eight, sixteen, thirty two, sixty
four, one hundred twenty eight
• Count up by powers of two

29 2628 2527 24 23 22 21 20

64 32 16 8 4 2 1
512 256 128
Octal (base 8)
• Shorter & easier to read than binary
• 8 digits: 0, 1, 2, 3, 4, 5, 6, 7,
• Octal numbers
1368 = 1 * 82 + 3 * 81 + 6 * 80
= 1 * 64 + 3 * 8 +

6*1
= 9410
Hexadecimal (base 16)
• Shorter & easier to read than binary
• 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
• “0x” often precedes hexadecimal numbers
0x123 = 1 * 162 + 2 * 161 + 3 * 160
= 1 * 256 + 2 * 16 + 3*
1
= 256 + 32 + 3
= 291
Decimal Binary Octal Hexadecimal

Counting 0
1
00000
00001
0
1
0
1
2 00010 2 2
3 00011 3 3
4 00100 4 4
5 00101 5 5
6 00110 6 6
7 00111 7 7
8 01000 10 8
9 01001 11 9
10 01010 12 A
11 01011 13 B
12 01100 14 C
13 01101 15 D
14 01110 16 E
15 01111 17 F
16 10000 20 10
10
Fractional Number
• Point: Decimal Point, Binary Point, Hexadecimal
point
• Decimal
247.75 = 2x102+4x101+7x100+7x10‐1+5x10‐2
• Binary
10.101= 1x21+0x20+1x2‐1+0x2‐2+1x2‐3
• Hexadecimal
6A.7D=6x161+10x160+7x16‐1+Dx16‐2
Converting To and From Decimal

Successive
Decimal10
0123456789 Weighted
Division
Successive Multiplication
Weighted
Multiplication Division
Successive Weighted
Division Multiplication
Octal8 Hexadecimal16
01234567 0123456789ABCDEF
Binary2
01

12
Decimal ↔ Binary

Successive
Division

a) Divide the decimal number by 2; the remainder is the LSB of the binary
number.
b) If the quotation is zero, the conversion is complete. Otherwise repeat step
(a) using the quotation as the decimal number. The new remainder is the
next most significant bit of the binary number.

Weighted
Multiplication

a) Multiply each bit of the binary number by its corresponding bit‐


weighting factor (i.e., Bit‐0→20=1; Bit‐1→21=2; Bit‐2→22=4; etc).
b) Sum up all of the products in step (a) to get the decimal
number.
Decimal to Binary : Subtraction Method
• Goal Desired decimal number: 12
– Good for human
32 16 8 4 2 1
– Get the binary weights to =32
1
add up to the decimal 32 16 8 4 2 1 too much
quantity 0 1 =16
• Work from left to right 32 16 8 4 2 1 too much
a
• (Right to left – may fill in 1s =8
0 0 1
that shouldn’t have been ok, keep going
there – try it). 32 16 8 4 2 1
=8+4=12
0 0 1 1 DONE
32 16 8 4 2 1
answer
0 0 1 1 0 0
32 16 8 4 2 1
Decimal to Binary : Division Method
• Good for computer: Divide decimal number by 2
and insert remainder into new binary number.
– Continue dividing quotient by 2 until the quotient is 0.
• Example: Convert decimal number 12 to binary

12 div 2 = ( Quo=6 , Rem=0) LSB


6 div 2 = (Quo=3, Rem=0)
3 div 2 = (Quo=1,Rem=1)
1 div 2 = ( Quo=0, Rem=1) MSB

1210= 1 1 00 2
Conversion Process Decimal ↔ BaseN

Successive
Division

a) Divide the decimal number by N; the remainder is the LSB of the ANY
BASE Number .
b) If the quotient is zero, the conversion is complete. Otherwise repeat
step (a) using the quotient as the decimal number. The new remainder
is the next most significant bit of the ANY BASE number.

Weighted
Multiplication

a) Multiply each bit of the ANY BASE number by its corresponding bit‐
weighting factor (i.e., Bit‐0→N0; Bit‐1→N1; Bit‐2→N2; etc).
b) Sum up all of the products in step (a) to get the decimal number.
Decimal ↔ Octal Conversion
The Process: Successive Division
• Divide number by 8; R is the LSB of the octal
number
• While Q is 0
• Using the Q as the decimal number.
• New remainder is MSB of the octal number.
8 94 r11 6  LSB
1 9410 = 1368
8 11 r3
0
8 1 r1  17
MSB
Decimal ↔ Hexadecimal Conversion
The Process: Successive Division
• Divide number by 16; R is the LSB of the
hex
number
• While Q is 0
• Using the Q as the decimal number.
• New remainder is MSB of the hex number.
16 94 5r  E  LSB
0 9410 = 5E16
16 5 r5 
MSB
Example: Hex → Octal
Example:
Convert the hexadecimal number 5AH into its octal equivalent.
Solution:
First convert the hexadecimal number into its decimal equivalent, then
convert the decimal number into its octal equivalent.
11
5 8 90 r  2 
A
16 16 LSB
1
0
1
8 11 r3
16 1
0
80 + 10
= 9010 8 1 r1 
MSB
 5AH = 1328
19
Example: Octal → Binary
Example:
Convert the octal number 1328 into its binary equivalent.
Solution:
First convert the octal number into its decimal equivalent, then convert the
decimal number into its binary equivalent.
45
1 3 2 2 90 r  0  LSB
22
82 81 80 2 45 r1
11
64 8 1 2 22
5
r0 1328 = 10110102
2 11 r1
64 + 24 + 2 2
= 9010 2 5 r1
1
2 2 r0
0 20
2 1 r  1  MSB
Binary ↔ Octal ↔ Hex Shortcut
• Relation
• Binary, octal, and hex number systems
• All powers of two
• Exploit (This Relation)
•Make conversion easier.

21
Substitution Code
Convert 0101011010101110011010102 to hex using
the 4‐bit substitution code :

5 6 A E 6
A

0101 0110 1010 1110 0110 1010

56AE6A16
Substitution Code

Substitution code can also be used to convert binary to


octal by using 3‐bit groupings:

2 5 5 2 7 1 5
2
010 101 101 010 111 001 101 010

255271528
Other Representation
• Signed & Unsigned Number
• Signed number last bit (one MSB) is signed bit
Assume: 8 bit number
Unsigned 12 : 0000 1100
Signed +12 : 0000 1100
Signed ‐12 : 1000 1100
• Complement number
Unsigned binary 12 =
00001100
1’s Complement of 12 = 1111 0011 24
Thanks

25

You might also like