Numerical Analysis
Binary Numbers
Internally, computers store information using electronic switches. These switches can be on (represented by the number 1) or off (represented by the number 1). If we can convert a decimal number into a binary number, then we can store that number in a computer.
Definition. An n-digit binary number is a sequence
(bn−1,…,b1,b0)2
where bi∈{0,1} for 0≤i<n.
To distinguish between number systems, we will use the notation (xn−1,…,x1,x0)b, where x is a digit in the number system and b is the system's base. For example, the notation 10112 represents the binary number 1011, while the notation 101110 represents the decimal number 1011.
Decimal to Binary
Converting Integers
We convert decimal integers to binary by dividing by 2 successively and recording the remainders until we reach a quotient of 0. For example, the number 53:
53÷2=26 R 26÷2=13 R 13÷2=6 R 6÷2=3 R 3÷2=1 R 1÷2=0 R 101011
Reading the recorded remainders from top to bottom, we have the binary number 1010112.
Converting Rationals
Converting rationals to binary is similar to converting integers, except the steps are reversed. We multiply by two successively and record the integer parts, moving away from the decimal point towards the right. For example, the number 0.7:
.7×2=.4+.4×2=.8+.8×2=.6+.6×2=.2+.2×2=.4+.4×2=.8+⋮101100
Notice that the process repeats after four steps and continues indefinitely. Thus,
0.710=.1011001100110…2=.101102,
where the overbar notation denotes infinitely repeated digits. From these last two sections, we see that
53.710=110101.101102.
Floating Point Representation