CS计算机代考程序代写 Integer Numbers

Integer Numbers

Number Systems
■ Unary, or marks: ◆ /////// = 7
◆ /////// + ////// = /////////////
■ Grouping lead to Roman Numerals:
◆ VII+V=VVII=XII
■ Better: Indo Arabic Numerals: ◆ 7+5=12=1·10+2

Positional Number System
■ The value represented by a digit depends on its position in the number.
■ Ex:
◆ How to decode it?
1 * 103 + 8 * 102 + 3 * 101 + 2 * 100
1 * 1000 8 * 100 3 * 10 2* 1
1000 800 320
1832
1
8
3
2

Positional Number Systems (base b)
■ Select a number as the base b
■ Define an alphabet of b–1 symbols plus a
symbol for zero to represent all numbers
■ Use an ordered sequence of 1 or more digits d to represent numbers
■ The represented number is the sum of all digits, each multiplied by b to the power of the digit’s position i
Number = ∑ (di·bi) i=0
num digits

Arabic/Indian Numerals
■ Base (or radix): 10 (decimal)
◆ The alphabet (digits or symbols) is 0..9
■ We use the Arabic symbols for the 10 digits ◆ Has ZERO!
■ Numerals introduced to Europe by Leonardo Fibonacci in his Liber Abaci
◆ In 1202
◆ So useful!

Arabic/Indian Numerals
■ The Italian mathematician Leonardo Fibonacci
■ Also known for the Fibonacci sequence
◆ 1,1,2,3,5,8,13,21
Non-European not on the exam. ☺

Base Conversion
Three cases:
I. From any base b to base 10
II. From base 10 to any base b
III. From any base b to any other base c

From Base b to Base 10 •Base(radix): b
• Digits (symbols): 0 … (b – 1)
• Sn-1Sn-2….S2S1S0
Value = Σ (Sibi)
Use summation to transform any base to decimal
n-1
i=0

From Base b to Base 10
■ Example: 12345 = ?10
= 1 * 53 + 2 * 52 + 3 * 51 + 4 * 50 = 125 + 50 + 15 + 4
= 194
■ Example: 2015 = ?10
= 2 * 52 + 0 * 51 + 1 * 50 = 50 + 1
= 51

From Base 10 to Base b
■ Use successive divisions
■ Remember the remainders
■ Divide again with the quotients