Introduction to Chapter 2.
- This is chapter 2. You should read it.
- You may have figured this from the previous chapter, but
- The mathematical foundations of computer science are strong.
- Even at the lowest level, we use mathematics in computing.
- A number system that employs the idea of on/off will probably come into play
- We need to distinguish numbers systems in many programming applications.
- The integers are the numbers
- 1, 2, 3, ...
- and -1, -2, -3 ...
- And 0
- We frequently limit the integers we use because
- We can not represent infinitely different numbers.
- And there are infinitely different integers.
- So we generally only represent a range of numbers.
- From a minimum to a maximum.
- Think a scoreboard.
- The other numbers we frequently represent we call floating point numbers
- These are a subset of the rational numbers.
- Think numbers with a decimal point.
- But again, we can only represent so many digits.
- We will discuss both of these more in chapter 3, and in programming again and again.
- We need to discuss positional number systems.
- In our (human) history we have had many different ways to represent numbers.
- Today we mostly use a base 10 positional number system.
- This will go back to middle school or earlier.
- What does 437 mean?
- For example if I have 437 dollars.
- I really have 400 dollars + 30 dollars + 7 dollars.
- The number 437 can be expressed as $4\times10^2+3\times10^1+7\times10^0$
- Starting from the right, we have
- Single units.
- Then tens units
- Then 100s units
- And so on.
- The position is important because that tells us what to multiply the digit by to get the number of units it represents.
- Since we are raising 10 to different powers this is a base 10 number system.
- Also known as the decimal system.
- Note in base 10, we use 10 digits, 0, 1, 2, 3, 4, ... , 9 to represent all possible positive numbers.
- This is a convenient and quick way to represent numbers.
- We will study three bases other than base 10
- We will discuss in detail base two or binary.
- We will use base 8 or octal as one shorthand for binary.
- We will use base 16 or hexadecimal as another shorthand for binary.
- In the end our goals for this chapter are
- Distinguish between integers and floating point numbers.
- Describe a positional number system.
- Convert numbers from other bases to base 10
- Convert numbers from base 10 to other bases.
- Describe and use base 2, 8 and 16