Number Representation
(数の表現)
Discrete Mathematics I
2nd lecture, September 26, 2014
http://www.sw.it.aoyama.ac.jp/2014/Math1/lecture2.html
Martin J. Dürst
© 2005-14 Martin
J. Dürst Aoyama Gakuin
University
Today's Schedule
- Last week's homework, Moodle registration
- How to watch videos of this lecture
- History of numbers and numerals
- The historic origin of numbers: 1
- Creating natural numbers starting from 1
- The discovery of 0
- Positional notation
Summary of Last Lecture
- Mathematics is an important base for Information Technology
- Discrete Mathematics I mainly covers discrete mathematics (logic,...)
- Mathematics is a tool, a language, and a way of thinking
- English is very important for Information Technology
- English is best learned by diving in and practicing
Last Week's Homework
- Create your account on http://moo.sw.it.aoyama.ac.jp
- Enroll for Discrete
Mathematics I (deadline: Sept. 25 (Thursday))
- Solve the quiz Simple
Arithmetic in English (repeat until you get a perfect score; deadline:
Sept. 25, 20:00)
- Use highschool texts or the Web to refresh your knowledge about
positional notation of numbers and numeral systems with different bases
(decimal,...)
- Find/buy/lend a book about discrete mathematics
Problems with Moodle Registration
- Students with multiple accounts
- Confirmation email not received
- Wrong enrollment key (first letter is UPPER CASE)
- Enrollment key:
- Wrong email address, name,...: Click on your name in the upper left
corner, then choose Settings → My profile settings → Edit Profile
(exception: username)
- Not yet enrolled: Enrollment extended by one day; deadline: Sept. 26
(today!)
- Special problems: Talk to me after this lecture
Quiz Confusion
How to Watch Videos
The video of the first lecture is available via a link from Moodle.
The video plugin/application is supported as follows:
- Windows XP~8.1Pro: IE7~11, Firefox 3.6~, Chrome; Windwos Media Player
9.0~/Silverlight 5.0
- Mac OSX 10.5.7~: Safari 4.0~, Firefox 3.6~, Silverlight 5.0
- iPad, iPad2, iPad3: iOS 4.3~: Mobile Safari
- iPhone 4.0~, iPod touch 4th generation~: iOS 4.3~: Safari; Mediasite
iPhone/iPod application (free download from Apple App Store)
- Android: 4.1.x~ (Jellybean): Native browser, Chrome Mobile; 4.0.x (Ice
Cream Sandwich): Chrome Mobile
- Linux: OpenSUSE/Ubuntu: Install FFmpeg Plugin for Chromium Web
Browser
- Blackberry 10~: Native browser
Userid
and password is available in the news
forum.
They are the same for all students, but only for students of this lecture!
Please use the video soon to review the lecture.
Please be careful when watching the video on a mobile device (may be
expensive!).
History of Numbers and Numerals
(Georges Ifrah: The Universal History of Numbers, John Wiley
& Sons, 1998)
- Humans have used many different representations of numbers throughout
history
- The first number represented was 1
- Representations such as |, ||, |||,... are most frequent
- For bigger numbers, using groups of 10 is most frequent
(20 (French 80: quatre-vingt=4-20) and 60 (minutes, seconds) also
exist)
The Shape of Numerals
- Chinese numerals: 一、二、三、亖
- Roman numerals: I, II, III, IIII (or IV)
- (Arabic-)Indic numerals: ١, ٢, ٣ (used in
Arabic)
- (European-)Arabic numerals: 1, 2, 3
- Chinese numerals: 十、廿、...
- Roman numerals: X, XX,...
Creating the Natural Numbers Starting with 1
Peano Axioms (Guiseppe Peano, 1858-1932)
- 1 is a natural number (1∈ℕ)
- If a is a natural number, then s(a) is a
natural number (s(a) is the successor of
a)
(a∈ℕ ⇒ s(a)∈ℕ)
- There is no natural number x so that
s(x) = 1
- If two natural numbers are different, then their successors are
different
(a∈ℕ, b∈ℕ, a ≠ b ⇒
s(a) ≠ s(b))
- If we can prove a property for 1,
and we can prove, for any natural number a, that if a
has this property then s(a) also has this
property,
then all natural numbers have this property.
(Nowadays, it is usual to start with 0 rather than with 1.)
Number Representation using Peano Axioms
1 |
1 |
2 |
s(1) |
3 |
s(s(1)) |
4 |
s(s(s(1))) |
5 |
s(s(s(s(1)))) |
6 |
s(s(s(s(s(1))))) |
7 |
s(s(s(s(s(s(1)))))) |
... |
... |
Axioms of addition:
- a + 1 = s(a)
- If a and b are natural numbers, a +
s(b) = s(a + b)
(a∈ℕ, b∈ℕ ⇒ a + s(b)
= s(a + b))
Calculate 2 + 3 using Peano arithmetic:
Associative Laws
(associative properties)
A binary operation represented by operator △ is associative if all
operands a, b, and c:
(a△b) △ c = a △ (b△c)
Examples:
- Addition of natural numbers is associative.
- Multiplication of natural numbers is associative.
- Multiplication of matrices is associative.
Proof of Associativity of Addition using Peano Axioms
What we want to prove:
Associative law for addition: (d + e) + f =
d + (e + f)
Let's prove this for all values of f.
- Let's distinguish two cases: f=1 and
f=k+1
- If f = 1, then (d + e) + 1 = s(d + e) [by
the 1st axiom of addition, with (d+e) for
a]
= d + s(e) [by the 2nd axiom of addition, with
d for a and e for b]
= d + (e + 1) [by the 1st axiom of addition,
backwards, with e for a]
- Assuming that associativity holds for f = k (i.e.
(d + e) + k = d + (e
+ k)), let's prove associativity for f =
k+1, i.e let's prove
(d + e) + k = d + (e
+ k) ⇒ (d + e) +
(k+1) = d + (e + (k+1)):
(d + e) + (k+1) = (d +
e) + s(k) [by the 1st axiom of addition, with
k for a]
= s((d + e) + k) [by the 2nd axiom of
addition, with (d+e) for a and k for
b]
= s(d + (e + k)) [using the assumption]
= d + s(e + k) [by the 2nd
axiom of addition, backwards, with d for a and
(e+k) for b]
= d + ((e + k) + 1) [by the 1st axiom of
addition, with (e+k) for a]
= d + (e + (k + 1)) [using the case
f=1, with e for d and k for
e]
Q.E.D. [using the 5th Peano axiom, with f for a and
the property (d + e) + f = d +
(e + f)]
Comments on Proof
- Because we have not yet established associativity, we always have to use
parentheses.
- Once we have proved associativity, we can eliminate the parentheses.
- This proof uses mathematical induction.
- Peano Axiom 5 can be seen as the basis for mathematical
induction.
- We will look at mathematical induction more closely later.
The Discovery of 0
- The latest (natural/integer) number discovered by humans
- Discovered around 800 A.D. in India
- Discovery spread westwards to Arabia and Europe, eastwards to China and
Japan
More Arithmetic Operations
Exponentiation (e.g. 23):
Two raised to the power of three is eight.
Two to the power of three is eight.
Two to the three (third) is eight.
The third power of two is eight.
Five to the power of four is six hundred
twenty-five.
Three raised to the power of four is eight-one.
Modulo operation (remainder):
Twenty modulo six is two.
Twenty-five modulo seven is four.
Positional Notation: Decimal Notation
Number representations before positional notation:
Chinese (Han) numerals: 二百五十六、二千十三
Roman numerals: CCLVI, MMXIII
Example of decimal notation: 256 = 2×102 + 5×101 +
6×100
Example containing 0: 206 = 2×102 + 0×101 +
6×100
Generalization:
dn...d1d0
= dn×10n+...+d1×101+d0×100
Example with decimal point: 34.56 = 3×101 + 4×100 +
5×10-1 + 6×10-2
Binary Numeral System
(the base of a number is often given as a subscript)
10100112 = 1×26 + 0×25 + 1×24
+ 0×23 + 0×22 + 1×21 + 1×20
=
1×64 + 0×32 + 1×16 + 0×8 + 0×4 + 1×2 + 1×1 =
64 + 16 + 2 + 1 =
83
Base Conversion: Base b to Base 10
Calculate the sum of each of the digits multiplied by its positional
weight.
The positional weight is a power of b, the zeroth power for the
rightmost digit.
The power increases by one when moving one position to the left.
Base Conversion: Base 10 to Base b
Take the number to convert as the first quotient.
Repeatedly take the quotient of the previous division, and divide it by the
base b,
adding the remainder as a digit to the result from right to left.
dividend |
quotient |
remainder |
digits of the result |
|
23 |
|
|
23 |
11 |
1 |
1 |
11 |
5 |
1 |
11 |
5 |
2 |
1 |
111 |
2 |
1 |
0 |
0111 |
1 |
0 |
1 |
10111 |
23 divided by 2 is 11 remainder 1
11 divided by 2 is 5 remainder 1
5 divided by 2 is 2 remainder 1
2 divided by 2 is 1 remainder 0
1 divided by 2 is 0 remainder 1
23 = 11×21 + 1×20
= 5×22 + 1×21 + 1×20
= 2×23 + 1×22 + 1×21 + 1×20
= 1×24 + 0×23 + 1×22 + 1×21 +
1×20 = 10111
Using Horner's rule: 23 = (((1×2 + 0)×2 +
1×)2 + 1)×2 + 1
Base Conversion: Base b to Base c
- General method: Convert via base 10
Example: base 3 → base 10 → base 5
- Shortcut 1: If b is a power of c (or the other way
round), then convert the digits in groups
Example 1: base 3 → base 9 (9 is 32, therefore make groups of
two digits and convert to a single digit)
Example 2: base 8 → base 2 (8 is 23, therefore convert each
digit to a group of three digits)
- Shortcut 2: If both b and c are powers of
d, then convert via base d
Example: base 4 → base 8
because 4 = 22 and 8 = 23, d = 2
therefore, convert base 4 → base 2 → base 8 (use shortcut 1 two
times)
Base Conversion Shortcut Example
Convert 47623 (base 8) to base 4.
8 = 23, 4 = 22, therefore convert base 8 → base 2
→ base 4
476238 →
4 |
7 |
6 |
2 |
3 |
base 8 |
100 |
111 |
110 |
010 |
011 |
convert each base-8 digit to three base-2 digits |
1001111100100112
1 |
00 |
11 |
11 |
10 |
01 |
00 |
11 |
split base 2 into groups of two digits |
1 |
0 |
3 |
3 |
2 |
1 |
0 |
3 |
convert two base-2 digits to one base-4 digit |
→ 103321034
Hexadecimal Numbers
1AF = 1×162 + A×161 + F×160 = 1×256 + 10×16 + 15×1 = 256 + 160
+ 15 = 431
Values of hexadecimal (base 16) digits
digit (upper case) |
digit (lower case) |
value (decimal) |
A |
a |
10 |
B |
b |
11 |
C |
c |
12 |
D |
d |
13 |
E |
e |
14 |
F |
f |
15 |
Bases Frequently Used in IT
base |
name (adjective) and abbreviation |
(reason for) use |
constants in programming languages |
2 |
binary, bin |
used widely in logic and circuits |
0b101100 (Ruby,...) |
8 |
octal, oct |
shortened form of binary (rare these days) |
024570 (C and many others) |
10 |
decimal, dec |
for humans |
1234567 (all languages) |
16 |
hexadecimal, hex |
shortened form of binary, 1 byte (8bits) can be represented with two
digits |
0xA3b5 (C and many others) |
Correspondence between binary and hexadecimal numbers
10 |
2 |
16 |
0 |
0000 |
0 |
1 |
0001 |
1 |
2 |
0010 |
2 |
3 |
0011 |
3 |
4 |
0100 |
4 |
5 |
0101 |
5 |
6 |
0110 |
6 |
7 |
0111 |
7 |
8 |
1000 |
8 |
9 |
1001 |
9 |
10 |
1010 |
A |
11 |
1011 |
B |
12 |
1100 |
C |
13 |
1101 |
D |
14 |
1110 |
E |
15 |
1111 |
F |
16 |
10000 |
10 |
Powers of 2
n |
2n |
16 進法 |
0 |
1 |
1 |
1 |
2 |
2 |
2 |
4 |
4 |
3 |
8 |
8 |
4 |
16 |
10 |
5 |
32 |
20 |
6 |
64 |
40 |
7 |
128 |
80 |
8 |
256 |
100 |
9 |
512 |
200 |
10 |
1'024 ≈103 (kilo) |
400 |
11 |
2'048 |
800 |
12 |
4'096 |
1000 |
16 |
65'536 |
1'0000 |
20 |
1'048'576 ≈ 106 (mega) |
10'0000 |
30 |
1'073'741'824 ≈ 109 (giga) |
4000'0000 |
40 |
1'099'511'627'776 ≈ 1012 (tera) |
100'0000'0000 |
Homework: Jokes
Question: Why do computer scientist always think Christmas and Halloween are
the same?
Question: At what age do Information Technologists celebrate "Kanreki"
(還暦)
This Week's Homework
- If not yet completed, solve Simple
Arithmetic in English TODAY (until
22:00)
- Solve Arithmetic
and Base Conversion until October 2, 22:00
- Try to find an answer to the joke questions (no need to submit)
- Use highschool texts or the Web to refresh your knowledge about
propositions, logic, and functions
Glossary
- number
- 数
- numeral
- 数字
- natural number
- 自然数
- discovery
- 発見
- origin
- 原点
- positional notation
- 位取り表現
- perfect score
- 満点
- confusion
- 混乱
- representation
- 表現
- exponentiation
- べき乗演算
- Modulo operation
- モジュロ演算
- remainder
- 剰余 (余り)
- decimal notation (decimal numeral system)
- 十進法
- Chinese numerals
- 漢数字
- Roman numerals
- ローマ数字
- discovery
- 発見
- axiom
- 公理
- Peano axioms
- ペアノの公理
- successor
- 後者
- property
- 性質
- arithmetic
- 算術
- associative law (property)
- 結合律
- operation
- 演算
- operator
- 演算子
- operand
- 被演算子
- binary operation
- 二項演算
- proof
- 証明
- prove
- 証明する
- Q.E.D. (quod erat demonstrandum)
- 証明終了
- parenthesis
- (丸・小) 括弧、複数 parentheses
- mathematical induction
- 数学的帰納法
- remainder
- 余り、剰余
- subscript
- 下付き文字 (添え字)
- generalization
- 一般化
- decimal point
- 小数点
- base
- 基数
- base conversion
- 奇数変換
- positional weight
- (その桁の) 重み
- dividend (or numerator)
- 被除数、実 (株の配当という意味も)
- divisor (or denominator, modulus)
- 除数、法
- quotient
- 商 (割り算の結果)
- Horner's rule
- ホーナー法
- digit
- 数字
- shortcut
- 近道
- upper case
- 大文字
- lower case
- 小文字
- binary
- 二進数 (形容詞)
- octal
- 八進数 (形容詞)
- decimal
- 十進数 (形容詞)
- hexadecimal
- 十六進数 (形容詞)
- circuit
- 回路
- constant
- 定数
- joke
- 冗談
- submit
- 提出する
- proposition
- 命題
- function
- 関数