0% found this document useful (0 votes)
32 views2 pages

Number System & Calculation in C Language

The document explains various base numbering systems including Decimal, Binary, Hexadecimal, and Octal, collectively referred to as Base_b systems. It outlines the representation of numbers in these systems, conversion methods to and from base_10, and provides examples of how to convert between Binary and Hexadecimal as well as Binary and Octal. Key points include the use of specific prefixes for Hexadecimal (0x) and Octal (0o) numbers.

Uploaded by

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

Number System & Calculation in C Language

The document explains various base numbering systems including Decimal, Binary, Hexadecimal, and Octal, collectively referred to as Base_b systems. It outlines the representation of numbers in these systems, conversion methods to and from base_10, and provides examples of how to convert between Binary and Hexadecimal as well as Binary and Octal. Key points include the use of specific prefixes for Hexadecimal (0x) and Octal (0o) numbers.

Uploaded by

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

**Number System & Calculation**

(A) Base-b system


*Basic Concepts
There are many numbering system in IT, the most notable ones are Decimal (base_10), Binary
(base_2), Hexadecimal (base_16), Octal (base_8)........ and they are called “Base_b” system in
general
Note: The 4 mentioned systems are the most common and most important ( for students )

*Base_b representation:
𝑖(𝑏) = 𝑑𝑛 𝑑𝑛−1 … 𝑑1 𝑑0 … 𝑑−1 𝑑−𝑚 = ∑𝑛𝑝=−𝑚 𝑑𝑝 . (𝑏)𝑝
for example:
11101.11(2) = 1 × 24 + 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 + 1 × 2−1 + 1 × 2−2 = 29.75
Note: 29.75 is a base_10 number, which is what we use normally

(B) Converting to any Base_b system (3 Steps )


Step1: Convert that number to base_10, say we’d obtain 𝑖(10)
Step2: Devide 𝑖(10)by “b” (b is the system’s base we are trying to convert to);
until the resultant is zero (0)
and we rearrange all the obtained remainder like shown
[picture]
Step3: If 𝑖(10) is a real number with fractions (i.e: 1.2; 6.75...) then we do the following
[picture]

(C) Binary System


uses zeros (0) and ones (1)

(D) Hexadecimal System


Note: all Hexadecimal numbers have a prefix “0x” at the start

Digit Value
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
A 10
B 11
C 12
D 13
E 14
F 15
Note: There is a quick transformation between base_2 (binary) and Base_16 (hexadecimal)
- FOUR consecutive digits in a base_2 represent ONE base_16 digit
for example: 111011101
we divide the number into sections of FOUR digits

1 1101 1101
1 D D
so the number in the base_16 system will be: 0x1DD

(E) Octal System


Note: all Octal numbers have a prefix “0o” at the start
Uses: {0, 1, 2, 3, ....,7}
Note: There is a quick transformation between base_2 (binary) and Base_8 (Octal)
-THREE consecutive digits in base_2 represent ONE base_8 digit
for example: 235.64(8)
each number represents THREE digits in base_2

2 3 5 6 4
010 011 101 110 100
so 235.64(8) = 010011101.110100(2)
or 010011101.1101 (removes the right-most zeros)

You might also like