0% found this document useful (0 votes)
17 views49 pages

1.number Systems Ver1

Uploaded by

Alex Akyas Jones
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)
17 views49 pages

1.number Systems Ver1

Uploaded by

Alex Akyas Jones
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/ 49

CAO- ITS 62704

Number Systems and


Codes
WHAT YOU WILL LEARN

• Decimal 0-9=10=Base 10
• Binary= 1,0=2= Base 2
• Hexadecimal=0-9, A-F= Base 16

• BD
• DB
• HD
• DH
• HB
• BH
• Selected areas covered in this chapter:
– Understanding and Converting between
number systems.
• Decimal, binary, hexadecimal.
– Advantages of the hexadecimal number
system.
Objectives
• Counting in hexadecimal.
– Representing decimal numbers using
the BCD code.
• Pros and cons of using BCD.
• Differences between BCD and
straight binary.
– Purpose of alphanumeric codes such as
ASCII code.
– Parity method for error detection.
• Determine the parity bit to be
attached to a digital data string.
Binary is a language written with a
combination of ones (1) and zeros (0) that
computers use to carry out commands, inputs,
or functions.
Whatever you write onto a computer, a
machine inside processes the input and
converts it into binary. It's like using a
translator!
2-1 Binary to Decimal Conversion
• Convert binary to decimal by summing the positions that contain a 1:
• 100110 =(2^5)+ (2^2)+ (2^1)= 32+4+2=38
Example 2^7 2^6 2^5 2^4 2^3 2^2 2^1 Answer
2^0
128 64 32 16 8 4 2 1
B D

100110 1 0 0 1 1 0
32 4 2 38
10110101 1 0 1 1 0 1 0 1
• An example with a greater number of bits:
128 32 16 4 1 181
D B
45 0 0 1 0 1 1 0 1 101101
76 1 0 0 1 1 0 0 1001100
150 1 0 0 1 0 1 1 0 10010110

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-1 Binary to Decimal Conversion

• Reverse process described in 2-1.


–Note that all positions must be accounted for.

• Another example:

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-1 Binary to Decimal Conversion

• The double-dabble method avoids addition of


large numbers:
– Write down the left-most 1 in the binary number.
– Double it and add the next bit to the right.
– Write down the result under the next bit.
– Continue with steps 2 and 3 until finished with
the binary number.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-1 Binary to Decimal Conversion

• Binary numbers verify the double-dabble method:

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-1 Binary to Decimal Conversion

Repeated
Division
Divide the decimal
number by 2.
Write the remainder
after each division
until a quotient of
zero is obtained.
The first remainder
is the LSB.
The last is the MSB.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-1 Binary to Decimal Conversion

Exercise
Convert the following binary numbers to decimal
111
1001
11001
10001
11000

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-1 Binary to Decimal Conversion

Exercise
Convert the following decimal to binary

32
50
80
125
300

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
Why we use
Hexadecimal?
HEXADEMAL
• Hex numbers are compact and use
less memory, so more numbers
can be stored in computer systems.
Their small size also makes input-
output handling easier compared to
other numbering formats. Because
it's easy to convert hexadecimal to
binary and vice versa, the system
is widely used in computer
programming.
• Hexadecimal number is 4 bits
equivalent
• 0000 -1111; 0-F
2-3 Hexadecimal Number System

To perform conversions
between hex & binary, it
is necessary to know the
four-bit binary numbers
(0000 - 1111), and their
equivalent hex digits.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-3 Hexadecimal Number System

Relationships between
hexadecimal, decimal,
and binary numbers.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
Colours are defined in html using the hex format.
MAC Addresses
• The Media Access Control
(MAC) address is a binary
number used to uniquely
identify computer network
adapters:hardware address,
are physically burned into the
network hardware during the
manufacturing process, or
stored in firmware, and
designed to not be modified.

• MAC addresses are 12-digit


(48-bit) hexadecimal
numbers. By convention, they
are usually written in one of
the following formats:
• MM:MM:MM:SS:SS:SS
• Hexadecimal is often used when
developing new software or trying to trace
Memory Dump
program errors. ,
The contents of part of
Assembly Codecan
the computer memory & hold the key to
help solve many problems. When the
Machine Code
memory contents are output to a printer or
monitor, this is known as a MEMORY
DUMP
• Computer memory can be referred to
directly using machine code or assembly
code
• troubleshooting.
• they are essentially low-level languages
that directly access the memory chips in
the computer
• easier, faster and less error-prone to write
code compared to binary. Using true
machine code (which uses binary) is very
cumbersome, and it takes a long time to
key in the values
• It is easy to mistype the digits in a ‘sea of
1s and 0s’.
• Why is hexadecimal important in memory
addressing?
• Its a much shorter way to represent what would
otherwise be written in binary. It is also very nice
and easy to convert hex to binary and back. Each
4 digits of binary corresponds to one digit of hex.
Convention and convenience: hex shows more
clearly what relationship various pointers have to
address segmenting
2-3 Hexadecimal Number System

• Hexadecimal allows convenient handling of long


binary strings, using groups of 4 bits—Base 16
– 16 possible symbols: 0-9 and A-F

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-3 Hexadecimal Number System – Hex to Decimal

• Convert from hex to decimal by multiplying


each hex digit by its positional weight.

• In a 2nd example, the value 10 was substituted


for A and 15 substituted for F.

Ronald Tocci/Neal Widmer/Gregory Moss


Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Applications, 10e
Columbus, OH 43235
All rights reserved.
2-3 Hexadecimal Number System – Decimal to Hex

• Convert 42310 to hex:

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-3 Hexadecimal Number System – Decimal to Hex

• Convert 21410 to hex:

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
Decimal to Hex Conversion

Method II:
Use repeated division by radix.
16 | 1564


97
16|_____ R = 12 = C
6
16|_____ R=1
0 R=6

N = 61C 16
2-3 Hexadecimal Number System – Decimal to Hex to Binary

• Convert decimal 378 to a 16-bit binary number


by first converting to hexadecimal.
2-3 Hexadecimal Number System – Decimal to Hex

Exercise
Convert the following decimals to hex

100
180
250
320
550
1600

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-3 Hexadecimal Number System – Hex to Decimal

Exercise
Convert the following Hexadecimals to Decimals

111
A12
AD5
5F5A
9E7C

Ronald Tocci/Neal Widmer/Gregory Moss


Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Applications, 10e
Columbus, OH 43235
All rights reserved.
Binary to Hex Conversion

1. Divide binary number into 4-bit groups

01 1 0 0 0 0 1 1 1 0 0
Pad with 0’s
If unsigned number

2. Substitute hex digit for each group


Pad with sign bit
if signed number 61C16
2-3 Hexadecimal Number System – Hex to Binary

• Leading zeros can be added to the left of the MSB


to fill out the last group.

For practice, verify that BA616 = 1011101001102

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
Hexadecimal to Binary Conversion
Example

1. Convert each hex digit to equivalent binary

(1 E 9 C)16

(0001 1110 1001 1100)2


2-3 Hexadecimal Number System – Binary to Hex

• Convert from binary to hex by grouping bits in four


starting with the LSB.
– Each group is then converted to the hex equivalent
• The binary number is grouped into groups of four
bits & each is converted to its equivalent hex digit.

For practice, verify that 101011111 2 = 15F16

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-3 Hexadecimal Number System – Counting in Hex

• When counting in hex, each digit position can


be incremented (increased by 1) from 0 to F.
– On reaching value F, it is reset to 0, and the
next digit position is incremented.

Example:
38,39,3A,3B,3C,3D,3E,3F,40,41,42
When there is a 9 in a digit position, it
becomes an A when it is incremented.

With three hex digits, we can count from 00016 to FFF16


which is 010 to 409510 — a total of 4096 = 163 values.
2-3 Hexadecimal Number System – Hex to Binary

Exercise
Convert the following Hex to Binary

987
B125
A6F8
12CD4
FF7D3

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-4 BCD Code

• Binary Coded Decimal (BCD) is a widely used


way to present decimal numbers in binary form.
– Combines features of both decimal and binary
systems.
• Each digit is converted to a binary equivalent.
• BCD is not a number system.
– It is a decimal number with each digit encoded
to its binary equivalent.
• A BCD number is not the same as a straight
binary number.
– The primary advantage of BCD is the relative
ease of converting to and from decimal.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-4 BCD Code

• Convert the number 87410 to BCD:


– Each decimal digit is represented using 4 bits.
• Each 4-bit group can never be greater than 9.

• Reverse the process to convert BCD to decimal.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-4 BCD Code

• Convert 0110100000111001 (BCD) to its


decimal equivalent.

Divide the BCD number into four-bit


groups and convert each to decimal.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-4 BCD Code

• Convert 0110100000111001 (BCD) to its


decimal equivalent.

Divide the BCD number into four-bit


groups and convert each to decimal.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-4 BCD Code

• Convert BCD 011111000001 to its decimal


equivalent.

The forbidden group represents


an error in the BCD number.

Ronald Tocci/Neal Widmer/Gregory Moss


Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Applications, 10e
Columbus, OH 43235
All rights reserved.
2-6 Putting It All Together

Decimal numbers 1 – 15 in binary, hex, BCD, Gray

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-7 The Byte, Nibble, and Word

• Most microcomputers handle and store binary


data and information in groups of eight bits.
– 8 bits = 1 byte.
• A byte can represent numerous types of data/information.
• Binary numbers are often broken into groups
of four bits.
– Because a group of four bits is half as big as a
byte, it was named a nibble.
• A word is a group of bits that represents a
certain unit of information.
– Word size can be defined as the number of bits
in the binary word a digital system operates on.
• PC word size is eight bytes (64 bits).
Copyright ©2007 by Pearson Education, Inc.
Columbus, OH 43235
All rights reserved.
2-8 Alphanumeric Codes

• Represents characters and functions found on


a computer keyboard.
– 26 lowercase & 26 uppercase letters, 10 digits,
7 punctuation marks, 20 to 40 other characters.
• ASCII – American Standard Code for Information
Interchange.
– Seven bit code: 27 = 128 possible code groups
– Examples of use: transfer information between
computers; computers & printers; internal storage.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-8 Alphanumeric Codes

ASCII – American Standard Code


for Information Interchange

See the entire table on page 49 of your textbook.


Copyright ©2007 by Pearson Education, Inc.
Columbus, OH 43235
All rights reserved.
2-9 Parity Method for Error Detection

• Binary data and codes are frequently moved


between locations:
– Digitized voice over a microwave link.
– Storage/retrieval of data from magnetic/optical disks.
– Communication between computer systems
over telephone lines, using a modem.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-9 Parity Method for Error Detection

• Electrical noise can cause errors during


transmission.
– Spurious fluctuations in voltage or current present
in all electronic systems.

• Many digital systems employ methods for error


detection—and sometimes correction.
– One of the simplest and most widely used schemes
for error detection is the parity method.
Copyright ©2007 by Pearson Education, Inc.
Columbus, OH 43235
All rights reserved.
2-9 Parity Method for Error Detection

• The parity method of error detection requires the


addition of an extra bit to a code group.
– Called the parity bit, it can be either a 0 or 1,
depending on the number of 1s in the code group.
• There are two parity methods, even and odd.
– The transmitter and receiver must “agree” on
the type of parity checking used.
• Even seems to be used more often.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-9 Parity Method for Error Detection

• Even parity method—the total number of bits in


a group including the parity bit must add up to
an even number.
– The binary group 1 0 1 1 would require the addition
of a parity bit 1, making the group 1 1 0 1 1.
• The parity bit may be added at either end of a group.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-9 Parity Method for Error Detection

• Odd parity method—the total number of bits in a


group including the parity bit must add up to an
odd number.
– The binary group 1 1 1 1 would require the addition
of a parity bit 1, making the group 1 1 1 1 1.

The parity bit becomes a part of the code word.


Adding a parity bit to the seven-bit ASCII
code produces an eight-bit code.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-10 Applications

• When ASCII characters are transmitted there


must be a way to tell the receiver a new
character is coming.
– There is often a need to detect errors in the
transmission as well.
• The method of transfer is called asynchronous
data communication.
2-10 Applications

• An ASCII character must be “framed” so the


receiver knows where the data begins and ends.
– The first bit must always be a start bit (logic 0).
• ASCII code is sent LSB first and MSB last.
– After the MSB, a parity bit is appended to check
for transmission errors.
– Transmission is ended by sending a stop bit (logic 1).
END of Chapter

You might also like