+ All Categories
Home > Documents > 1 Introduction Two fundamental types in almost any programming...

1 Introduction Two fundamental types in almost any programming...

Date post: 19-Mar-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
8
Copyright @ 2011 Frank Pfenning & Ananda Gunawardena Lecture 02 Representing Data 1 Introduction Two fundamental types in almost any programming language are Booleans and integers. Booleans are comparatively straightforward: they have two possible values (true and false) and conditionals to test boolean values. Integers . . . ,-2,-1, 0, 1, 2, . . . are considerably more complex, because there are infinitely many of them. Because memory is finite, only a finite subrange of them can be represented in computers. In this lecture we discuss how integers are represented, how we can deal with the limited precision in the representation, and how various operations are defined on these representations. 2 Binary Representation of Natural Numbers
Transcript
Page 1: 1 Introduction Two fundamental types in almost any programming …guna/15-123S11/Lectures/Lecture02.pdf · computer by two different voltages, usually "off" for 0 and "on" for 1.

Copyright @ 2011 Frank Pfenning & Ananda Gunawardena

Lecture 02

Representing Data

1 Introduction Two fundamental types in almost any programming language are Booleans and integers.

Booleans are comparatively straightforward: they have two possible values (true and

false) and conditionals to test boolean values. Integers . . . ,−2,−1, 0, 1, 2, . . . are

considerably more complex, because there are infinitely many of them. Because memory

is finite, only a finite subrange of them can be represented in computers. In this lecture

we discuss how integers are represented, how we can deal with the limited precision in

the representation, and how various operations are defined on these representations.

2 Binary Representation of Natural Numbers

Page 2: 1 Introduction Two fundamental types in almost any programming …guna/15-123S11/Lectures/Lecture02.pdf · computer by two different voltages, usually "off" for 0 and "on" for 1.

Copyright @ 2011 Frank Pfenning & Ananda Gunawardena

Page 3: 1 Introduction Two fundamental types in almost any programming …guna/15-123S11/Lectures/Lecture02.pdf · computer by two different voltages, usually "off" for 0 and "on" for 1.

Copyright @ 2011 Frank Pfenning & Ananda Gunawardena

Page 4: 1 Introduction Two fundamental types in almost any programming …guna/15-123S11/Lectures/Lecture02.pdf · computer by two different voltages, usually "off" for 0 and "on" for 1.

Copyright @ 2011 Frank Pfenning & Ananda Gunawardena

Page 5: 1 Introduction Two fundamental types in almost any programming …guna/15-123S11/Lectures/Lecture02.pdf · computer by two different voltages, usually "off" for 0 and "on" for 1.

Copyright @ 2011 Frank Pfenning & Ananda Gunawardena

Page 6: 1 Introduction Two fundamental types in almost any programming …guna/15-123S11/Lectures/Lecture02.pdf · computer by two different voltages, usually "off" for 0 and "on" for 1.

Copyright @ 2011 Frank Pfenning & Ananda Gunawardena

Page 7: 1 Introduction Two fundamental types in almost any programming …guna/15-123S11/Lectures/Lecture02.pdf · computer by two different voltages, usually "off" for 0 and "on" for 1.

Copyright @ 2011 Frank Pfenning & Ananda Gunawardena

Page 8: 1 Introduction Two fundamental types in almost any programming …guna/15-123S11/Lectures/Lecture02.pdf · computer by two different voltages, usually "off" for 0 and "on" for 1.

Copyright @ 2011 Frank Pfenning & Ananda Gunawardena


Recommended