情報数学 I

第二回 (2013年 10月4日)
数の表現
Number Representation

Martin J. Dürst

http://www.sw.it.aoyama.ac.jp/2013/Math1/lecture2.html

AGU

© 2005-13 Martin J. Dürst 青山学院大学

今日の予定

前回のまとめ

前回からの宿題

Moodle の登録の諸問題

Simple Arithmetic in English のクイズ

数と数字の歴史

(資料: Georges Ifrah: The Universal History of Numbers, John Wiley & Sons, 1998)

数字の形

1 から作り上げる自然数

(ペアノの公理; Peano Axioms; Guiseppe Peano, 1858-1932)

  1. 1 は自然数
  2. a が自然数であれば s(a) は自然数 (s は successor, 後者)
  3. s(x) = 1 という x は存在しない
  4. 違う自然数の後者が違う: abs(a) ≠ s(b)
  5. 1 がある性質を持ち、かつ
    任意の自然数 a がある性質をもつとき s(a) もこの性質を持つとき、
    全ての自然数はこの性質を持つ

(現在は 1 のではなく 0 からのスタートが普通)

 

ペアノの自然数の表現

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))))))
... ...

ペアノ風足し算

公理 (Axiom):

  1. a + 1 = s(a)
  2. ab が自然数の場合、a + s(b) = s(a + b)

2 + 3 をペアノ風で計算:

 
 

ペアノの公理による足算の結合律の証明

足算の結合律: (a + b) + c = a + (b + c)

c = 1 の場合: (a + b) + 1 = s(a + b) = a + s(b) = a + (b + 1)

c = k+1 の場合 (c = k の場合を前提に):

(a + b) + k = a + (b + k) ⇒? (a + b) + (k+1) = a + (b + (k+1))

(a + b) + (k+1) = (a + b) + s(k) = s((a + b) + k) = s(a + (b + k)) = a + s(b + k) = a + ((b + k) + 1) = a + (b + (k + 1))
Q.E.D.

0 の発見

More Arithmetic Operations

Exponentiation:

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 three 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

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

 

Base Conversion: Base b to Base c

 

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 8 16
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 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 1024 ≈103 (kilo) 400
11 2048 800
12 4096 1000
16 65536 10000
20 1048576 ≈ 106 (mega) 100000
30 1073741824 ≈ 109 (giga) 40000000
40 1099511627776 ≈ 1012 (tera) 10000000000

Glossary

exponentiation
べき乗演算
Modulo operation
モジュロ演算
remainder
剰余 (余り)
positional notation
位取り表現
decimal notation (decimal numeral system)
十進法
Chinese numerals
漢数字
Roman numerals
ローマ数字
generalization
一般化
decimal point
小数点
base
基数
base conversion
奇数変換
positional weight
(その桁の) 重み
dividend (or numerator)
被除数、実 (株の配当という意味も)
divisor (or denominator, modulus)
除数、法
quotient
商 (割り算の結果)
digit
数字
shortcut
近道
upper case
大文字
lower case
小文字
binary
二進数 (形容詞)
octal
八進数 (形容詞)
decimal
十進数 (形容詞)
hexadecimal
十六進数 (形容詞)
circuit
回路
constant
定数

冗談の宿題

Q: Why do computer scientist always think Christmas and Halloween are the same ?

質問: なぜ情報テクノロジーの専門家はクリスマスとハロウィーンをいつも誤解するか。

もう一つの冗談

質問: 情報テクノロジーで還暦は何歳か

次回までの宿題