0% found this document useful (0 votes)
55 views

Lecture - Why Binary and How We Interpret It

The document discusses binary representation in computers. It explains that binary is used because digital systems can reliably represent information with two stable states (on/off). Bits are grouped into containers to represent common data types like unsigned and two's complement signed integers. These integer representations allow binary numbers to be interpreted as positive and negative numbers within a given range. The document also introduces key concepts like abstraction that allow binary values to represent meaningful data in computer systems.

Uploaded by

me
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Lecture - Why Binary and How We Interpret It

The document discusses binary representation in computers. It explains that binary is used because digital systems can reliably represent information with two stable states (on/off). Bits are grouped into containers to represent common data types like unsigned and two's complement signed integers. These integer representations allow binary numbers to be interpreted as positive and negative numbers within a given range. The document also introduces key concepts like abstraction that allow binary values to represent meaningful data in computer systems.

Uploaded by

me
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

RICE

ELEC 220
Why Binary
And how we interpret it

ELEC 220, Fundamentals of Computer Engineering, Spring 2017 0


Logistics
• Canvas poll has been released
– Due 11:59 pm Jan 19th, this Thursday.
• Canvas Tip: Notification Preferences on Canvas
– Account > Notifications
• You can set your preferences for notifications
regarding Due Date, Announcement, etc.
• Here are the kinds of Notification Preferences:

• I recommend you have Announcements set to


Notify me right away.
• I strongly recommend you do not choose
Do not send me anything.
ELEC 220, Fundamentals of Computer Engineering, Spring 2017 1
Last Time..
• We saw a history of attempts to:
– Improve computing reliability.
• Reliability of the result
• Reliability of the machine
– Improve computing repeatability.
– Improve computing speed.

ELEC 220, Fundamentals of Computer Engineering, Spring 2017 2


Today’s topics
• Why binary?
• We can put our bits (binary digits) in special
containers.
• The containers we put our bits in represent key
data types we will use in programming:
– Unsigned integers
– 2’s complement signed integers
• Addition, subtraction and overflow
• Future topics
– Other types of numerical values
– And it’s not just about numbers

ELEC 220, Fundamentals of Computer Engineering, Spring 2017 3


Why a binary system?
• Why do we use a binary system i.e. two values?
– 1 and 0
– true and false
– on and off
– high and low
– left and right
– a and b
– 0 volts and 3 volts
– punched hole and no punched hole
– switch flipped on and switch flipped off
• Answer: many binary systems can be built to be very
stable i.e. we can put the system in one of two states
and it will tend to stay in that state.
– This is a fundamental requirement of doing reliable
computing!
ELEC 220, Fundamentals of Computer Engineering, Spring 2017 4
The cost of our binary switches
• We build a binary switch out of a single transistor.
• How much does a single transistor cost?

= 20,000,000 transistors
= 20,000,000 binary switches
[1] As Moore’s law turns 50, what does the future hold for the
transistor?, Mark Walton, arstechnica.com

• Using transistors, we can make binary switches that are


– Incredibly reliable and switch very rapidly
– In large quantities Babbage had his gears.
– And very, very inexpensive We have our transistors.

• Later this semester, we’ll look at transistors and how they


work.
ELEC 220, Fundamentals of Computer Engineering, Spring 2017 5
Abstraction
• What does this collection of symbols mean?
01010010010010010100001101000101

• Does this help?


OLOLOOLOOLOOLOOLOLOOOOLLOLOOOLOL
• Does this make it better or worse:
01,010,010,010,010,010,100,001,101,000,101
• How about this?
01010010010010010100001101000101
• For many of our system discussions, binary
means our symbols will be 1 and 0.
• So, what does this sequence of 1’s and 0’s mean?
ELEC 220, Fundamentals of Computer Engineering, Spring 2017 6
Our choice for representing
our binary system is 1 and 0
• To improve readability let’s write
01010010010010010100001101000101
as

0101 0010 0100 1001 0100 0011 0100 0101


• Let’s call our sequence x.
– There are 32 bits making up x.
• What we have to do is agree on how to interpret
these 32 bits.
• What are some possible interpretations?

ELEC 220, Fundamentals of Computer Engineering, Spring 2017 7


Bits, and groups of bits, and different containers
• The containers for bits will give us powerful
capabilities:
– Any system that can store bits can store any data we can
represent as bits.
– Any system that can send and receive bits can send and
receive any data we can represent as bits.

• And we define how we will interpret the bits.


• This is our first application of the key computer
engineering concept of Abstraction.
– We will describe a design at different levels of
representation.
– Lower-level details are hidden to offer a simpler
model at higher levels.

ELEC 220, Fundamentals of Computer Engineering, Spring 2017 8


Unsigned Binary Integers
• Given an n-bit number
n-1 n-2 n-3 … 3 2 1 0
xn-1 xn-2 xn-3 … x3 x2 x1 x0 where xi = 0 or 1

A polynomial
x = xn-1 2n-1 + xn-2 2n-2 + … + x1 21 + x0 20

• Range: 0 to 2n – 1
• Example
• 0000 0000 0000 0000 0000 0000 0000 10112
= 0 + … + 1×23 + 0×22 +1×21 +1×20
= 0 + … + 8 + 0 + 2 + 1 = 1110
• Using 32 bits (n = 32)
• Range: 0 to +4,294,967,295
• With this definition, our sequence
x = 0101 0010 0100 1001 0100 0011 0100 01012
= 1,382,172,99510
ELEC 220, Fundamentals of Computer Engineering, Spring 2017 9
Aside: Some Important Terminology
• Given an n-bit series of bits

n-1 n-2 n-3 … 3 2 1 0


xn-1 xn-2 xn-3 … x3 x2 x1 x0 where xi = 0 or 1

This (xn-1) is called the This (x0) is called the


most-significant bit least-significant bit

• Why might these terms be used?

ELEC 220, Fundamentals of Computer Engineering, Spring 2017 10


2s-Complement Signed Integers
• Given an n-bit number
n-1 n-2 n-3 … 3 2 1 0
xn-1 xn-2 xn-3 … x3 x2 x1 x0 where xi = 0 or 1
n -1 n-2
x = - x n-1 2 + x n-2 2 + ! + x1 2 + x 0 2
1 0

• Range: –2n – 1 to +2n – 1 – 1


• Example
• 1111 1111 1111 1111 1111 1111 1111 11002
= –1×231 + 1×230 + … + 1×22 +0×21 +0×20
= –2,147,483,648 + 2,147,483,644 = –410
• Using 32 bits
• Range: –2,147,483,648 to +2,147,483,647
• With this definition, our sequence remains
• x = 0101 0010 0100 1001 0100 0011 0100 01012
– = 1,382,172,99510
ELEC 220, Fundamentals of Computer Engineering, Spring 2017 11
2s-Complement Signed Integers
n-1 n-2 n-3 … 3 2 1 0
xn-1 xn-2 xn-3 … x3 x2 x1 x0 where xi = 0 or 1

n -1 n-2
x = - x n-1 2 + x n-2 2 + ! + x1 2 + x 0 2 1 0

• For n = 32, bit 31 is the sign bit


• xn-1= 1 for negative numbers
• xn-1 = 0 for non-negative numbers
• Non-negative numbers have the same unsigned
and 2s-complement representation
• –(–2n – 1) cannot be represented
• Some specific numbers
– 0: 0000 0000 … 0000
– –1: 1111 1111 … 1111
– Most-positive: 0111 1111 … 1111
– Most-negative: 1000 0000 … 0000
ELEC 220, Fundamentals of Computer Engineering, Spring 2017 12
Signed Negation of 2’s-Complement Signed Integers
• Rule: Complement the number and add 1
– Complement means, bit by bit, 1" = 0, 0" = 1
• Proof: Complement of x

x + x = 111 … 111( = −1
x + x = −1
x" + 1 = −x

• Example: negate +2
• +2 = 0000 0000 … 00102
• –2 = 1111 1111 … 11012 + 1
= 1111 1111 … 11102
ELEC 220, Fundamentals of Computer Engineering, Spring 2017 13
Stopped here in class

ELEC 220, Fundamentals of Computer Engineering, Spring 2017 14


Next Time
• Floating point (or scientific notation)
• Characters
• Abstractions

Thank you!

ELEC 220, Spring 2017 15

You might also like