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

EEE 204 - Lecture2

The document discusses number systems and data formats used in digital systems and computing. It defines basic units of data like bits, bytes and words. Common number systems are binary, octal and hexadecimal. Numbers can be represented in different bases using a positional notation system. Methods for converting between bases like binary, decimal and hexadecimal are presented, including dividing or multiplying by the base to obtain digits.

Uploaded by

furkanarslan1285
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 views16 pages

EEE 204 - Lecture2

The document discusses number systems and data formats used in digital systems and computing. It defines basic units of data like bits, bytes and words. Common number systems are binary, octal and hexadecimal. Numbers can be represented in different bases using a positional notation system. Methods for converting between bases like binary, decimal and hexadecimal are presented, including dividing or multiplying by the base to obtain digits.

Uploaded by

furkanarslan1285
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
You are on page 1/ 16

24.02.

2021

Chapter 2
Number Systems and Data Formats

Computers and digital systems understand logic 1 and 0 and process the
information that consists of them.

Logic 1 corresponds physically to 5 volts, while logic 0 corresponds to about 0


volts.

By combining these two symbols in any consecutive combination or in different


combinations; data, commands and different symbols are produced in a format
that digital systems can understand.

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Bits, Bytes, and Words

Nibble: 4-bit-width
• Byte: 8-bit width
• Word: 16-bit width
• Double word: 32-bit width
• Quad: 64-bit width

These lengths are associated to usual hardware. In the MSP430, for example,
registers are 16 bits wide. Notice the specific use of the term “word” for 16 bits.
Individual bits in a word are named after their position, starting from the right
with 0: bit 0 (b0), bit 1 (b1), and so on. Symbolically, an n-bit word is denoted as

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 1
24.02.2021

The rightmost bit, b0, is the least significant bit (lsb), while the leftmost one,
bn−1, is the most significant bit (msb).

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 2
24.02.2021

Number Systems

Numbers can be represented in different ways using 0’s and 1’s.

In this section we will talk about the most common conventions, starting with the
normal binary notation, which is a positional numerical system.

Our decimal system is positional, which means that any number is expressed by
a permutation of digits and can be expanded as a weighted sum of powers of ten,
the base of the system. Each digit contributes to the sum according to its position
in the string. Thus, for example,

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

This concept can be generalized to any base. A fixed-radix, or fixed-point positional


system of base r has r ordered digits 0, 1, 2, . . . “r−1”. Number notations
are composed of permutations of these r digits.

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 3
24.02.2021

Numbers are written as a sequence of digits and a point, called radix point, which
separates the integer from the fractional part of the number to the left and right side
of the point, respectively.

Here, each subscript stands for the exponent of the weight associated to the digit
in the sum. The leftmost digit is referred to as the most significant digit (MSB) and
the rightmost one is the least significant digit (LSB). If there were no fractional part
in equation the radix point would be omitted and the number would be called
simply an integer. If it has no integer part, it is customary to include a “0” as the
integer part. The number denoted by the equation represents a power series in r of
the form

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Well known number systems

Binary numbering system, base 2


Octal numbering system, base 8
Hexadecimal numbering system , base 16

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 4
24.02.2021

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Conversion Between Different Bases

The power expansion of a number may be used to convert from one base to
another, performing the right hand side operations in the target system.

Conversion from Base r to Decimal

Notice that for hexadecimal conversion, all hex digits are interpreted in their
decimal values for the sum.

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 5
24.02.2021

power of base 2 increases to the right for integer part and decreases to the left for
fractional part

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Conversion from Decimal to Base r

Integer Conversion
One popular procedure for converting decimal integers into base r is the repeated
division method. This method is based on the division algorithm, and consists in
successively dividing the number and quotients by the target radix r until the quotient
is 0. The successive remainders of the divisions are the digits of the number in base r ,
starting from the least significant digit: divide the number by r and take the remainder
as a0; divide the quotient by r , and the remainder as a1, and so on. Let us illustrate
with a pair of examples.

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 6
24.02.2021

Conversion from Decimal to Base r

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Fractional Part

Conversion of decimal fractions can be done by the repeated multiplication


method: Multiplying the number by r , the integer part of the first product becomes
most significant digit a−1. Discard then the integer part and multiply again the new
fractional part by r to get the next digit a−2. The process continues until one of the
following conditions is met:

• A zero decimal fraction is obtained, yielding a finite representation in radix r; or


• A previous fractional part is again obtained, having then found the periodic
representation in radix r; or
• the expression in base r has the number of digits allocated for the process.

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 7
24.02.2021

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 8
24.02.2021

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Mixed Numbers with Integer and Fractional Parts

Example:
Convert (376.9375)10 to base 2. First convert the integer part by successive
divisions by 8:
Division Quotient Remainder

376/2 188 0
188/2 94 0
94/2 47 0
47/2 23 1
23/2 11 1
11/2 5 1
5/2 2 1
2/2 1 0
1/2 0 1

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 9
24.02.2021

We now convert the fractional part by successive multiplications:

Multiplication product Integer Part


.9375x2 1.875 1
.875x2 1.75 1

0.75x2 1.5 1
0.5x2 1 1

(376.9375)10 =(101111000.111)

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Binary and Hexadecimal Systems

The lower the base, the more digits required to represent a number. The binary
numerical system, the ‘natural’ one for digital systems, is quite inconvenient for
people.
Associate each hex digit to four binary digits, from right to left in the integer part and
from left to right in the fractional part.

(12345)10 =(11 0000 0011 1001)2 =(3039)H

(2748)2 =(1010 1011 1100)2 =(ABC)H

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 10
24.02.2021

there is a one to one correspondence between each hex digit and a group of four
bits, a nibble.

1010011= 53h or 0x53


1101100110000010 =0xD982

Base 16 number system or hexadecimal number system has been universally adopted
in the embedded systems literature as well as in debuggers. Thus, memory addresses,
register contents, and pretty much everything else are expressed in hexadecimal
integers without implying that they are a number.

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

The seven-segment display consists of eight light-emitting diodes (LED), in the


form of seven segments called a, b, c, d, e, f, and g plus a dot. Each diode is
connected to one port pin as shown in the figure. When the pin shows a high
voltage state, the respective LED is turned on.

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 11
24.02.2021

Unsigned Binary Arithmetic Operations

Addition

0+0=0
0 + 1 =1 + 0 = 1
1 + 1 = 10
Example:

Add the binary equivalents of 27 and 18

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Example:
Add these decimal numbers to each others in binary numbering system
152.75 and 236.375

152.75 = 10011000.11B
236.375 = 11101100.011B

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 12
24.02.2021

Subtraction

Subtraction follows the usual rules too. When the minuend digit is less than the
subtrahend digit, a borrow should be taken. For subtraction, the rules are

When a borrow is needed, it is taken from the next more significant digit of the
minuend, from which the borrow should be subtracted. Hence, actual subtraction
can be considered to be carried out using three digits: the minuend, the subtrahend,
and the borrowed digit.
Example: Subtract 231 from 325 using binary subtraction.

1 0 1 0 0 0 1 0 1 = 325
- 0 1 1 1 0 0 1 1 1 =231

0 1 0 1 1 1 1 0 =94

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Subtraction by Complement’s Addition

Two’s Complement Concept and Application

Negative numbers are represented in a computer system by two’s complement.


In mathematical subtraction, two’s complement of subtrahend number is added
to minuend number. By the way subtraction operation is obtained.

13710001001
011101101’s complement
1
+
01110111 2’s complement of 137
Since the answer has a carry (9 bits), the
result is positive. Dropping this carry, we have
11011000
the solution to this subtraction 01001111B =
+ 01110111 79.
carry 101001111 drop carry then =0x4F=(79)10
Introduction to Embedded Systems University of Gaziantep
EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 13
24.02.2021

Example: subtract 125 from 232 by subtraction addition method.

125 0111 1101


2321110 100000010111(1’s complement) 00011000 (2’s complement)

0111 1101
+ 0001 1000
10010101
Since the sum does not yield a carry (8 bits), the result is negative, with an absolute.
To find its decimal equivalent we take 2’ complement.

10010101 01101011(2’s complement)=(-107)10

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Important Remark When the subtraction of A − B is realized by complement


addition, the presence of a carry in the addition means that the difference is
nonnegative, A ≥ B. On the other hand, if the carry is 0, there is a need for a borrow,
A < B, and the result is the negative of the complement of the sum.

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 14
24.02.2021

Operations in Hexadecimal System

Example: Add two hexadecimal numbers to each otthers.


0xB6 and 0x5F

Sixteen’s Complement: find the difference for each hex digit with respect to F and
then add 1 to the result.

Example: A set of data for bytes and words is given in hex notation as
0×7A, 0×9F24, 91H and CFA20h Find the two’s complement of each one using
hex notation and verify the response in binary.

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

Representation of Numbers in Embedded Systems

Numbers can be real valued or integer valued. Real-valued numbers can have fractions.
But integer-valued numbers don't have fractions. Besides, numbers can be defined as
signed or unsigned in embedded systems.

Summary on numbers in digital systems:


1. Only 0’s and 1’s are allowed. No other symbols such as minus sign, point, radix,
exponent, are available.
2. In a given environment or problem, all representations have a fixed length of N
bits, so only a finite set of 2N numbers can be represented.
3. Arithmetic operations may yield meaningless results irrespectively of their
theoretical mathematical validity.

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 15
24.02.2021

QUESTIONSS

Introduction to Embedded Systems University of Gaziantep


EEE204 Prof. Dr. Ergun Erçelebi Department of EEE

eeee 16

You might also like