Docsity

Encoding and Representing Data: Integers, Floating Points, Text, and Unicode, Slides of Computer Science

Partial preview of the text

Download Encoding and Representing Data: Integers, Floating Points, Text, and Unicode and more Slides Computer Science in PDF only on Docsity!

Encoding Things for Computers

Section 17.

Chapter 3

Standards

  • A very old idea.
  • Sometimes there aren’t any.
  • But they’re very common.
  • And there’s a general trend in the direction of standards.

Wishing for Standards

http://www.sheldonbrown.com/tire-sizing.html

Integers

The first step is obvious:

Integers

The first step was obvious:

But what about this:

sign bit

But What Happens Now?

Another Problem

What should we do about:

Another Problem

What should we do about:

If we always want two places after. : Then we could write:

And then always treat it as though the decimal point were there.

Floating Point

We’ll do it in decimal:

Number Floating Point

4.32 4.32e

456.2 4.56e+

Multiply by 10 2

Floating Point

We’ll do it in decimal:

Number Floating Point

4.32 4.32e

456.2 4.56e+

.0004 4.0e-

Multiply by 10 -

Floating Point

We’ll do it in decimal:

Number Floating Point

4.32 4.32e

456.2 4.56e+

.0004 4.0e-

56784657846352*34526251 1960561349752268586352

1960561349752268586352/2 9.802806748761343e+

Rounding Error

int(_) 4388

Where did the .664 cents go?

We can force Python to round instead of truncate.

Our balance is $1,567.38 and the interest rate is 2.8%:

Text

Computers have revolutionized our world. They have changed the course of our daily lives, the way we do science, the way we entertain ourselves, the way that business is conducted, and the way we protect our security.

Text

Computers have revolutionized our world. They have changed the course of our daily lives, the way we do science, the way we entertain ourselves, the way that business is conducted, and the way we protect our security.

Les ordinateurs ont révolutionné notre monde. Ils ont changé le cours de notre vie quotidienne, notre façon de faire la science, la façon dont nous nous divertissons, la façon dont les affaires sont menées, et la façon dont nous protégeons notre sécurité.