100% found this document useful (1 vote)
306 views55 pages

Mathematics Concepts For Computing: Number Base System

This document provides an overview of number base systems that are important for computing. It discusses converting between decimal, binary, octal, and hexadecimal number bases. The key topics covered are base systems, conversion methods between different bases, and some important terms related to number representation in computing. The goal is for learners to understand how data is represented and stored in different number bases in computers.

Uploaded by

vln
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
100% found this document useful (1 vote)
306 views55 pages

Mathematics Concepts For Computing: Number Base System

This document provides an overview of number base systems that are important for computing. It discusses converting between decimal, binary, octal, and hexadecimal number bases. The key topics covered are base systems, conversion methods between different bases, and some important terms related to number representation in computing. The goal is for learners to understand how data is represented and stored in different number bases in computers.

Uploaded by

vln
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
You are on page 1/ 55

Mathematics Concepts For Computing

AQ010-3-1-MCFC & Version 2

Number Base System


Topic & Structure of The Lesson

Topic Outline
Base System
Conversion of Number Bases
Computer Arithmetic
Data Representation
Data Storage

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide ‹2› of 9


Learning Outcomes

• At the end of this topic, You should be able


to
• Know how data are represented and
stored in computers

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide ‹3› of 9


Key Terms You Must Be Able To
Use
• If you have mastered this topic, you should be able to use the following
terms correctly in your quiz, test and exams:
• Binary
• Octal
• Decimal/denary
• Hexadecimal
• 1’s complement
• 2’s complement
• Sign
• Exponent
• Mantissa
• register

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide ‹4› of 9


Introduction
• Commonly, people are used to calculating and to
representing number in decimal number base system
(base 10 system)
• In computing, interested in several other number bases
notably Binary number system.
• Binary number represented by binary digits 0 and 1.
• Its convenient to build electronic switches that can be in
on only two states, off and on.
• Therefore, the use of bits 0 or 1, off or on, true or false,
largely depends on the application we have in mind.

AQ010-3-1-Mathematical Concepts for Computing Number Base System ‹#›


Main Teaching Points

• Base Systems
Decimal System (Base 10)
Binary System (Base 2)
Octal System (Base 8)
Hexadecimal System (Base 16)

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide 4 (of 17)
Number System
• Human beings use decimal (base 10) number systems
for counting and measurements.

• Computers use binary (base 2) number system, as they


are made from binary digital components (known as
transistors) operating in two states - on and off.

• In computing, we also use hexadecimal (base 16)


or octal (base 8) number systems, as a compact form
for represent binary numbers.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Base system
Number Binary Octal Decimal/ Hexadecimal
system Denary
Base 2 8 10 16
Symbols 0 0 0 0
used 1 1 1 1
(Digits) 2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8
9 9
A
B
C
D
E
F

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide 4 (of 18)
Main Teaching Points

• Conversion of Number Bases


 Decimal System Binary System
 Decimal System Octal System
 Decimal system Hexadecimal System
 Binary System Octal System
 Binary System Hexadecimal System
 Octal System Hexadecimal System

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide 5 (of 17)
Conversion of Integer and fraction
Decimal System to Binary System
• Integer and fraction are done separately.
• Method :
(a)Integer – repeated division by 2 and note the remainder
(answer :from bottom to up). Stop until get 0 or 1.
(b)Fraction – multiplied by 2 and the integral result is noted
(answer : from top to bottom. Stop until fractional part
become zero.
Example :
(a) 53
(b) 238.65625

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Conversion of Integer and fraction
Decimal System to Octal System
• Integer and fraction are done separately.
• Method :
(a)Integer – repeated division by 8 and note the remainder
(answer :from bottom to up). Stop until get less than 8.
(b)Fraction – multiplied by 8 and the integral result is noted
(answer : from top to bottom. Stop until fractional part
become zero.
Example :
(a) 102
(b) 92.8125

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Conversion of Integer and fraction
Decimal System to Hexadecimal System
• Integer and fraction are done separately.
• Method :
(a)Integer – repeated division by 16 and note the remainder
(answer :from bottom to up). Stop until get less than 16.
(b)Fraction – multiplied by 16 and the integral result is
noted (answer : from top to bottom. Stop until fractional
part become zero.
Example :
(a) 70
(b) 178.75
(c) 64.4

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Conversion of Integer and
fraction
Binary System to Decimal System
• Method : (exponential) – expressing the binary number
in expanded notation and calculating the sum of the
powers of 2 weighted by the digit in the position.

Example :
(a) 1011101
(b) 1011.1001

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Conversion of Integer and
fraction
Octal System to Decimal System
• Method : (exponential) – expressing the octal number in
expanded notation and calculating the sum of the
powers of 8 weighted by the digit in the position.

Example :
(a) 2417
(b) 224.35

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Conversion of Integer and
fraction
Hexadecimal System to Decimal System
• Method : (exponential) – expressing the hexa number in
expanded notation and calculating the sum of the
powers of 16 weighted by the digit in the position.

Example :
(a) 4BC
(b) A301.2F

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Conversion of Integer and fraction
Octal System to Binary System
• Each octal digit has a unique 3 digit binary representation
as given in the table.
• An octal value can be converted to a binary value by
replacing each octal digit by its equivalent binary
representation. Octal Binary
equivalent
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
AQ010-3-1-Mathematical Concepts for Computing Number Base System
Conversion of Integer and
fraction
Octal System to Binary System
• Example :
(a) Convert 120 (base 8) to Binary.
1 2 0
001 010 000
1208=10100002
(b) Convert 1074.35 (base 8) to Binary.
1 0 7 4. 3 5
001 000 111 100. 011 101
1074.358 =1000111100.0111012

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Conversion of Integer and
fraction
Binary System to Octal System
• Group 3-binary digits starting from the decimal point to
the left for integral value. (add zero to complete 3 digits)
• For fraction, group 3-binary digits from decimal point to
the right. (add zero to complete 3 digits)

• Example :
(a) Convert 1101110111 (base 2) to Octal.
(b) Convert 11011.10111 (base 2) to Octal.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Conversion of Integer and fraction
Hexadecimal System to Binary System
• Each hexa digit has a unique 4 digit binary representation
as given in the table.
• An hexa value can be converted to a binary value by
replacing each hexa digit by its equivalent binary
representation.
Hexadecimal Binary Hexadecimal Binary
equivalent equivalent
0 0000 8 1000
1 0001 9 1001
2 0010 A 1010
3 0011 B 1011
4 0100 C 1100
5 0101 D 1101
6 0110 E 1110
7 0111 F 1111

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Conversion of Integer and
fraction
Hexadecimal System to Binary System
• Example :
(a) Convert A76 (base 16) to Binary.
(b) Convert 3BE.C7 (base 16) to Binary.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Conversion of Integer and
fraction
Binary System to Hexadecimal System
• Group 4-binary digits starting from the decimal point to
the left for integral value. (add zero to complete 4 digits)
• For fraction, group 4-binary digits from decimal point to
the right. (add zero to complete 4 digits)

• Example :
(a) Convert 110011010(base 2) to Hexadecimal.
(b) Convert 1011011110.1111101(base 2) to
Hexadecimal.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Conversion of Integer and
fraction
Octal System to Hexadecimal System
• Example :
(a) 3054.17
Hexadecimal System to Octal System
• Example :
(a) 4AC.BE

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Example

10768 = ?16
1 0 7 6

001 000 111 110

2 3 E

10768 = 23E16

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Example

1F0C16 = ?8
1 F 0 C

0001 1111 0000 1100

1 7 4 1 4

1F0C16 = 174148

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Main Teaching Points

• Computer Arithmetic
 Binary Addition
 Binary Subtraction
 Octal Addition
 Octal Subtraction
 Hexadecimal Addition
 Hexadecimal Subtraction

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide 6 (of 17)
Computer Arithmetic
Binary Addition
 Performed in a similar way to decimal addition.
 If 1+0 = 1
 If 0+0 = 0
 If 1 + 1 = 0 + c (c=1 need to carry to the next column to
the left)
• If 1 + 1+ 1 = 1 + c (c=1 need to carry to the next column
to the left)

• Example:
(a) 1100 + 0101
(b) 11011.01 + 101.1101
(c) 111101.01 + 111100.1
AQ010-3-1-Mathematical Concepts for Computing Number Base System
Computer Arithmetic
Binary Subtraction
• If 1 – 1 = 0
• If 0 – 1 = ( need to borrow from the adjacent left column
of digit = 1)
• If the preceding left column is 1, it will reduce to 0.
• If the preceding left column is 0, the value of this column
changes to 1 and all preceding column of 0’s changed to
1 until 1 can changed to a 0.

• Example:
(a) 1100110 – 10111
(b) 110010.00 – 101.11
(c) 1100.11 – 101.10
AQ010-3-1-Mathematical Concepts for Computing Number Base System
Computer Arithmetic
Octal Addition
 Performed in a similar way to decimal addition.
 if the sum exceeds 7, subtract with 8 and carrying 1 to
the next column.

 Example:
(a) 5 + 4
(b) 447 + 622
(c) 37.54 + 72.74

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Computer Arithmetic
Octal Subtraction
• Apply the same method as subtract decimal number.
• Highest value when borrow is 8.

• Example:
(a) 4251 – 3476
(b) 345 – 126
(c) 245.24 – 157.56
(d) 5004.3 – 267.14

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Computer Arithmetic
Hexadecimal Addition
 Performed in a similar way to decimal addition.
 if the sum exceeds 15, subtract with 16 and carrying 1 to
the next column.

 Example:
(a) 8 + 9
(b) B83 + A2D
(c) C868 +72D9
(d) 9FB7.2 + E67.4A

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Computer Arithmetic
Hexadecimal Subtraction
• Apply the same method as subtract decimal number.
• Highest value when borrow is 16.

• Example:
(a) 72A4 – 4E86
(b) BA3 – AB4
(c) A047.3 – B58.41

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Representation

• How number are represented in digital


computer.
• Binary number system is the most natural
and conventional system to use for
representing number.
• 3 widely used system to represent +ve and
–ve numbers :
– Sign and magnitude
– 1’s complement
– 2’s complement

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide 8 (of 18)
Data Representation

• Take note:
1 byte = 8 bits
1 kb = 1024 byte
1 mb =1024 kb

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide 9 (of 18)
Data Representation
• Sign and Magnitude :
– Most significant bit represent sign and the rest
represent the magnitude (Absolute value).

Example 1: Suppose that n=8 and the binary representation


is 0 100 0001.
   Sign bit is 0 ⇒ positive
   Absolute value is 100 0001= 65
   Hence, the integer is +65
Example 2: Suppose that n=8 and the binary representation
is 1 000 0001.
   Sign bit is 1 ⇒ negative
   Absolute value is 000 0001 = 1
   Hence, the integer is -1
AQ010-3-1-Mathematical Concepts for Computing Number Base System
Data Representation
• Sign and Magnitude :

The drawbacks of sign-magnitude representation are:

1.There are two representations (0000 0000 and 1000


0000) for the number zero, which could lead to inefficiency
and confusion.

2.Positive and negative integers need to be processed


separately.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Representation
• 1’s complement :
– Negative values are obtained by complementing each
bit of positive number ( 0 to 1 and 1 to 0)
– Not commonly used.
– Difficulty in making comparisons and additional
complexity involved in adding numbers.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Representation
• 2’s complement :
• Add 1 to 1’s complement.
• Best method in terms of implementation of addition
and subtraction.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Representation

Example :
Using 2’s complement in an 8 bits register, show how the
computer would evaluate:
a) 2310 – 1410
b) 1410 – 2310
c) - 1410 - 2310

AQ010-3-1-Mathematical Concepts for Computing Number Base System


What Are Floating Point Numbers?

There are several ways to represent real numbers on computers.


• Fixed point places : for example, if you have four decimal digits,
you could represent 10.82, or 00.01. Another approach is to use
rational, and represent every number as the ratio of two
integers.
• Floating-point representation - the most common solution -
basically represents reals in scientific notation. Scientific
notation represents numbers as a base number and an
exponent.
• For example, 123.456 could be represented as 1.23456 x 102.
In hexadecimal, the number 123.ABC might be represented as
1.23ABC x 162.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


What Are Floating Point Numbers?

• Fixed-point has a fixed window of representation, which limits


it from representing very large or very small numbers. Also,
fixed-point is prone to a loss of precision when two large
numbers are divided.

• Floating-point, on the other hand, employs a sort of "sliding


window" of precision appropriate to the scale of the number.
This allows it to represent numbers from 1,000,000,000,000 to
0.0000000000000001 with ease.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Storage- IEEE Floating Point
Representation

The IEEE Standard for Floating-Point Arithmetic (IEEE


754) is a technical standard for floating-point computation
established in 1985 by the 
Institute of Electrical and Electronics Engineers (IEEE). 

In 32-bit single-precision floating-point representation:


•The most significant bit is the sign bit (S), with 0 for
positive numbers and 1 for negative numbers.
•The following 8 bits represent exponent (E).
•The remaining 23 bits represents fraction (F).

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Storage

IEEE Floating Point Representation


• Floating point numbers can be stored into 32-bits, by
dividing the bits into three parts:
the sign, the exponent, and the mantissa.

1 2 9 10 32

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Storage- Decimal to floating-point
conversion
Step 1 : Convert into binary number
Step 2 : Normalization :- Every binary number,
except the one corresponding to the number
zero, can be normalized by choosing the exponent
so that the radix point falls to the right of the leftmost
1 bit.

37.2510 = 100101.012 = 1.0010101 x 25

7.62510 = 111.1012 = 1.11101 x 22

0.312510 = 0.01012 = 1.01 x 2-2

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Storage- Decimal to floating-point
conversion

• Step 3 : The mantissa is the set of 0’s and 1’s to


the right of the radix point of the normalized
(when the digit to the left of the radix point is 1)
binary number.
Ex: 1.00101 X 23 (The mantissa is 00101)

 The mantissa is stored in a 23 bit field, so we add


zeros to the right side and store:
00101000000000000000000

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Storage- Decimal to floating-point
conversion

• Step 4 : The second field of the floating point number


will be the exponent.
• Add the bias to the exponent of two.
• the bias formula is 2(n-1) – 1, where n is the number of
bits in exponent filed.
• For IEEE 8-bit, n = 3, so the bias is 3.
• For IEEE 16-bit, n = 6, so the bias is 31.
• For IEEE 32-bit, n = 8, so the bias is 127.
• For the case, the bits is not enough to fill in 8 bits
provided, add zeros to the LEFT side.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Storage- Decimal to floating-point
conversion

– Exponent 5 is stored as (127 + 5) or 132


• 132 = 10000100
– Exponent -5 is stored as (127 + (-5)) or 122
• 122 = 01111010
• Step 5 : set sign bit, 1 for negative, 0 for positive,
according to the sign of the original number.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Storage- Decimal to floating-point
conversion
Example :
(a) Convert 2.625 to 8-bits floating point format with
3 bits for the exponent part with the bias of 3.
(b) A computer stores a number in a 16 bits using
floating number arrangement. First bit for the sign,
followed by 6 bits for the exponent with the bias of
31 and the remaining bits for mantissa. Show how
computer stores :
(i) 21.25
(ii) -66.5

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Storage- floating-point to Decimal
conversion

• Do the steps in reverse order


• In reversing the normalization step move the radix
point the number of digits equal to the exponent:
– If exponent is positive, move to the right
– If exponent is negative, move to the left

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Storage- floating-point to Decimal
conversion

Step 1: Separate into sign, exponent and mantissa field.


Step 2 : Extract the exponent and subtract the bias to
recover the actual exponent of two.
Step 3 :Extract the mantissa field and restore the
leading one.
Step 4 : De-normalize the number : move the binary
point. (positive exponent – move right/ negative
exponent – move left)
Step 5: Convert the binary value to decimal.
Step 6 : Set the sign of the decimal number according to
the sign bit of the original floating point.

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Storage- floating-point to Decimal
conversion
Example :
(a) Convert 8-bits floating point format 11100111
with 3 bits for the exponent part with the bias of
3.
(b) A computer stores a number in a 16 bits using
floating number arrangement. First bit for the
sign, followed by 6 bits for the exponent with the
bias of 31 and the remaining bits for mantissa.
What is the decimal value for:
(i) 1100 1101 1101 0000
(ii) 0011 1101 1000 0000

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Data Storage- floating-point to
Decimal conversion
• Formula
 
x (1+M) x

S---- Sign
E----Exponent
M—Mantissa or Magnitude

AQ010-3-1-Mathematical Concepts for Computing Number Base System


Quick Review Question

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide ‹52› of 9


Summary of Main Teaching Points

• Conversion

• Computer Arithmetic

• Data Representation

• Data storage

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide ‹53› of 9


Question and Answer Session

Q&A

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide ‹54› of 9


What we will cover next

Set Theory

AQ010-3-1-Mathematical Concepts for Computing Number Base System Slide ‹55› of 9

You might also like