Presentation is loading. Please wait.

Presentation is loading. Please wait.

Topic: Binary Encoding – Part 1

Similar presentations


Presentation on theme: "Topic: Binary Encoding – Part 1"— Presentation transcript:

1 Topic: Binary Encoding – Part 1
CMPT 120 Topic: Binary Encoding – Part 1

2 Last Lecture File I/O File input -> reading data from a file
File output -> writing data to a file

3 Learning Outcomes At the end of this course, a student is expected to:
Manipulate binary encodings of simple data types. Do conversions from binary system to decimal and vice versa Determine the range of representable values within binary system Do additions and incremental counting within binary system Decode/encode a bit string to/from its corresponding value (unsigned, 2's complement, ASCII)

4 Decimal numeral system
Today’s Menu Binary Encoding How characters are represented in computer memory How numbers are represented in computer memory But before to do this, we need to introduce decimal and binary numeral systems Counting and adding numbers in these numeral systems Converting binary numbers <-> decimal numbers Decimal numeral system Binary numeral system

5 So far, we have seen that …
Computer memory: integer colour floating point number character CPU instruction sound

6 Sequences of 0’s and 1’s We have already mentioned that
Computer hardware functions using two voltage levels See link Computers and Voltage Levels in Week 2 We represent these two voltage levels using 0’s and 1’s As our previous slide demonstrated, what a sequence of 0’s and 1’s represents depends on the context So, let’s have a look at what could a sequence of 0’s and 1’s represent

7 How characters are represented in computer memory
Source:

8 Numeral representation of characters
(UNICODE) Source:

9 Padding Notice ... From Slide 7: From ASCII Table: H -> versus H ->

10 How numbers are represented in computer memory
Let’s introduce a few numeral systems As we saw in our ASCII table, a character can be expressed in a variety of numeral systems For example: Hexadecimal numeral system Binary numeral system Decimal numeral system Octal numeral system

11 Decimal numeral system
Decimal -> (Base 10) Ten digits: When counting:

12 Decimal numeral system
When adding:

13 Binary numeral system Binary -> 2 (Base 2) Two digits:
Using the symbols of the binary numeral system makes it easier to talk about computer hardware (CPU architecture, CPU instruction set, memory content etc…) Binary -> (Base 2) Two digits: When counting:

14 Binary numeral system When adding:

15 Convert binary to decimal
First, let’s examine how we read numbers expressed in the decimal numeral system Consider the positional value of each digit in the decimal number below 25014

16 Convert binary to decimal
Applying the same algorithm, let’s convert the following number expressed in binary numeral system to its equivalent in decimal numeral system

17 Convert decimal to binary
We could use a table and map the binary number to its decimal number equivalent like we did when we mapped characters to their binary number equivalent

18 Convert decimal to binary
Applying the same algorithm as the one described in our reading, let’s convert the following number expressed in decimal numeral system to its equivalent in binary numeral system 213

19 Decimal numeral system
Summary Binary Encoding How characters are represented in computer memory How numbers are represented in computer memory But before to do this, we need to introduce decimal and binary numeral systems Counting and adding numbers in these numeral systems Converting binary numbers <-> decimal numbers Decimal numeral system Binary numeral system

20 Next Lecture Binary encoding
How numbers integers are represented in computer memory Unsigned integers Signed integers Sign and magnitude 1’s complement 2's complement How many values (range of values) can they represent


Download ppt "Topic: Binary Encoding – Part 1"

Similar presentations


Ads by Google