The Decimal Number System, Study notes of Computer Fundamentals

To convert from binary to hexadecimal, split the binary number into nibbles. Each nibble is a binary representation of a hexadecimal digit. Express 010011012 ...

Typology: Study notes

2022/2023

Uploaded on 03/01/2023

anshula
anshula 🇺🇸

4.4

(12)

243 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
computer hardware and data representation
ICS3U: Introduction to Computer Science
Decimal, Binary and Hexadecimal Systems
J. Garvin
Slide 1/15
computer hardware and data representation
The Decimal Number System
The number system that we use on a regular basis is the
decimal system.
It is based on powers of ten.
103102101100
1 000 100 10 1
Any number in the decimal system can be represented as a
sum of powers of 10 (multiplied as necessary).
J. Garvin Decimal, Binary and Hexadecimal Systems
Slide 2/15
computer hardware and data representation
The Decimal Number System
Example
Express 3 025 using powers of 10.
3 025 = 3000 + 20 + 5
= 3(1000) + 2(10) + 5(1)
= 3 ·103+ 2 ·101+ 5 ·100
J. Garvin Decimal, Binary and Hexadecimal Systems
Slide 3/15
computer hardware and data representation
The Binary Number System
Unlike us, digital computers do not use the decimal number
system.
In fact, computers do not use “numbers” at all. They use
electrical signals that are either high (on) or low (off).
It is convenient for us to use numbers to represent these two
states, and so we typically use 1 for high and 0 for low.
These two digits form the binary system.
J. Garvin Decimal, Binary and Hexadecimal Systems
Slide 4/15
computer hardware and data representation
The Binary Number System
A single binary digit (0 or 1) is called a bit in computer
terminology.
A fixed-length string of bits is called a byte.
The size of a byte used to be hardware-dependent, but has
since been standardized as 8 bits.
Occasionally, an 8-bit byte may be referred to as an octet.
A 4-bit string (half a byte) has a name as well: a nibble.
J. Garvin Decimal, Binary and Hexadecimal Systems
Slide 5/15
computer hardware and data representation
Converting Between Decimal and Binary
The binary number system is based on powers of two, similar
to how the decimal number system is based on powers of ten.
2726252423222120
128 64 32 16 8 4 2 1
It uses only the digits 0 and 1 to make all numbers.
As a decimal number made entirely of 9s “rolls over” when 1
is added, a binary number does the same when it is made
entirely of 1s.
Thus, the numbers 0-4 in binary are 0, 1, 10, 11 and 100.
We can express decimal values in binary by identfying powers
of two.
J. Garvin Decimal, Binary and Hexadecimal Systems
Slide 6/15
pf3

Partial preview of the text

Download The Decimal Number System and more Study notes Computer Fundamentals in PDF only on Docsity!

ICS3U: Introduction to Computer Science

Decimal, Binary and Hexadecimal Systems

J. Garvin

Slide 1/

The Decimal Number System

The number system that we use on a regular basis is the decimal system. It is based on powers of ten.

Any number in the decimal system can be represented as a sum of powers of 10 (multiplied as necessary).

J. Garvin — Decimal, Binary and Hexadecimal SystemsSlide 2/

c o m p u t e r h a r d w a r e a n d d a t a r e p r e s e n t a t i o n

The Decimal Number System

Example

Express 3 025 using powers of 10.

J. Garvin — Decimal, Binary and Hexadecimal Systems Slide 3/

c o m p u t e r h a r d w a r e a n d d a t a r e p r e s e n t a t i o n

The Binary Number System

Unlike us, digital computers do not use the decimal number system. In fact, computers do not use “numbers” at all. They use electrical signals that are either high (on) or low (off). It is convenient for us to use numbers to represent these two states, and so we typically use 1 for high and 0 for low. These two digits form the binary system.

J. Garvin — Decimal, Binary and Hexadecimal Systems Slide 4/

c o m p u t e r h a r d w a r e a n d d a t a r e p r e s e n t a t i o n

The Binary Number System

A single binary digit (0 or 1) is called a bit in computer terminology.

A fixed-length string of bits is called a byte.

The size of a byte used to be hardware-dependent, but has since been standardized as 8 bits.

Occasionally, an 8-bit byte may be referred to as an octet.

A 4-bit string (half a byte) has a name as well: a nibble.

J. Garvin — Decimal, Binary and Hexadecimal SystemsSlide 5/

c o m p u t e r h a r d w a r e a n d d a t a r e p r e s e n t a t i o n

Converting Between Decimal and Binary

The binary number system is based on powers of two, similar to how the decimal number system is based on powers of ten.

It uses only the digits 0 and 1 to make all numbers. As a decimal number made entirely of 9s “rolls over” when 1 is added, a binary number does the same when it is made entirely of 1s. Thus, the numbers 0-4 in binary are 0, 1, 10, 11 and 100. We can express decimal values in binary by identfying powers of two.

J. Garvin — Decimal, Binary and Hexadecimal SystemsSlide 6/

Converting Between Decimal and Binary

For example, let the binary representation of a number be a string of bits, such as 101.

The rightmost bit represents 2^0 , the bit to the left of it represents 2^1 , and the leftmost bit represents 2^2.

All bits that are 1 are included, whereas those that are 0 are not.

The decimal equivalent of 101 2 (the subscript 2 indicates that 101 is a binary number) is 2^2 + 2^0 = 4 + 1 = 5 10.

To convert in the other direction, take a number like 6 10 and identify all powers of two that are included in it.

6 = 4 + 2 = 2^2 + 2^1. Therefore, 6 10 = 110 2.

We can use one byte (with leading zeroes if necessary) to represent a value between 0 and 255. J. Garvin — Decimal, Binary and Hexadecimal SystemsSlide 7/

Converting Between Decimal and Binary

Example Express 19 10 in binary.

19 = 16 + 2 + 1 = 2^4 + 2^1 + 2^0. Therefore, 1910 = 00010011 2.

Example Express 29 10 in binary.

29 = 16 + 8 + 4 + 1 = 2^4 + 2^3 + 2^2 + 2^0. Therefore, 2910 = 00011101 2.

J. Garvin — Decimal, Binary and Hexadecimal SystemsSlide 8/

c o m p u t e r h a r d w a r e a n d d a t a r e p r e s e n t a t i o n

Converting Between Decimal and Binary

Example

Express 00101001 2 in decimal.

The included powers of two are 2^0 , 2^3 and 2^5. Therefore, 001010012 = 2^0 + 2^3 + 2^5 = 41 10.

Example

Express 10000101 2 in decimal.

The included powers of two are 2^0 , 2^2 and 2^7. Therefore, 001010012 = 2^0 + 2^2 + 2^7 = 133 10.

J. Garvin — Decimal, Binary and Hexadecimal Systems Slide 9/

c o m p u t e r h a r d w a r e a n d d a t a r e p r e s e n t a t i o n

The Hexadecimal Number System

Another number system is hexadecimal, which uses 16 digits. Since we do not have single-digit values beyond 9, we use the “numbers” A-F instead.

Dec Hex Dec Hex 0 0 8 8 1 1 9 9 2 2 10 A 3 3 11 B 4 4 12 C 5 5 13 D 6 6 14 E 7 7 15 F

Thus, we count 1, 2,.. ., 8, 9, A, B, C, D, E, F, 10, 11,... J. Garvin — Decimal, Binary and Hexadecimal Systems Slide 10/

c o m p u t e r h a r d w a r e a n d d a t a r e p r e s e n t a t i o n

Converting Between Hexadecimal and Binary

The hexadecimal number system is based on powers of sixteen.

163 162 161 160 4 096 256 16 1

There is an easy method to convert from hexadecimal to binary.

J. Garvin — Decimal, Binary and Hexadecimal SystemsSlide 11/

c o m p u t e r h a r d w a r e a n d d a t a r e p r e s e n t a t i o n

Converting Between Hexadecimal and Binary

Since 2^4 = 16, four bits (1 nibble) can be used to represent one hexadecimal digit. To express a hexadecimal number in binary, split the hexadecimal value into individual digits, then write each digit as a binary nibble.

Example Express 2A 16 in binary.

The first digit, 2, has a binary value of 0010. The second digit, A, has a binary value of 1010 (decimal 10). Therefore, 2A 16 = 00101010 2.

J. Garvin — Decimal, Binary and Hexadecimal SystemsSlide 12/