Appendix FNumbers in Binary, Octal, and Hexadecimal Representations For readers unfamiliar with binary and related bases, we digress here to consider three important numerical systems b
Trang 1Appendix F
Numbers in Binary, Octal, and
Hexadecimal Representations
For readers unfamiliar with binary and related bases, we digress here to consider three important numerical systems besides the decimal (base 10) system; these are binary (base 2), octal (base 8), and hexadecimal (base 16) Obviously, the decimal system uses ten number symbols (0, 1, 2, 3, 4, 5, 6,
7, 8, 9) that multiply 10 raised to some exponent The system is positional, with columns to the left of the decimal point indicating increasing powers
of 10, and those to the right, decreasing powers For example, 234.5 may be written as (2)(102) + (3)(101) + (4)(100)+ (5)(10–1) = 200 + 30 + 4 + 5/10 = 234.5 Table F.1 illustrates the procedure
By analogy, octal (base 8) uses an analogous scheme: eight number symbols (0, 1, 2, 3, 4, 5, 6, 7) and a base of 8 To see what the octal equivalent of 234.5
number indicates the base Obviously, if there is no subscript we are referring
to base 10
TABLE F.1
Positional Number Representation in Base 10 (e.g., 234.5)
Exponential notation … 10 3 10 2 10 1 10 0 10 –1 10 –2 10 –3 … Decimal notation … 1000 100 10 1 1/10 1/100 1/1000 …
TABLE F.2
Positional Number Representation in Base 8 (e.g., 352.4 8 = 234.5)
Exponential notation … 8 3 8 2 8 1 8 0 8 –1 8 –2 8 –3 …
Trang 2610 Modeling of Combustion Systems: A Practical Approach
Base 2 is ideal for constructing factorial designs because the system com-prises only two states for any factor: high and low In base 2, the only numbers we may use are 0 or 1 (We can use – and + in lieu of numeric symbols, but the point is that we only have two symbols at our disposal.)
As an example of binary math, the decimal number 14.75 is equivalent to
To find the octal equivalent for 14.75, we could go through the same routine
as before However, we can take a shortcut whenever two bases are related
case, we may group the base A symbols in groups of n and convert each
Therefore, we can group the base 2 symbols in groups of three (starting from the octal point and moving in each direction) and then convert each to its
12 = 18, 1102 = 68 Conversion to base 4 follows the same pattern: base 4 = 22,
so grouping 1110.112 in groups of two gives 11,10.112 = 32.34, since 112 = 34 and 10 = 24
For bases less than 10, we use a subset of the base 10 numerical symbols For bases greater than 10, we use letters as additional numerical symbols Thus, for base 16 we augment the symbols 0 through 9 with A = 10, B = 11,
simpler: EA.816 = 352.48 = 32,22.24 = 11,0010,1011.12 To find this, we first con-vert to base 2 using Table F.3 From it we note that E = 1110, A = 1010, and
8 = 1000 Putting these in series and eliminating leading and trailing zeros after the binary point, we have 1110,1010.1, and this is indeed the base 2
Delimiting the numerals in groups of threes (always beginning from the binary point and proceeding in either direction) rather than fours gives
Delimiting the binary number in groups of twos gives 11,10,10,10.10
Con-4
the procedure easier
TABLE F.3
Positional Number Representation in Base 2 (e.g., 1110.11 2 = 14.75)
Exponential notation … 2 3 2 2 2 1 2 0 2 –1 2 –2 2 –3 …
Decimal sum 8 + 4 + 2 + 0 + 1/2 + 1/4 = 14.75
Trang 3Numbers in Binary, Octal, and Hexadecimal Representations 611
Example 3.1 Conversion of Numbers among Bases
Problem statement: Convert 100 to its hexadecimal equivalent.
Then convert the hexadecimal number into the bases 2, 4, and 8 Which conversions are easier? Why?
Solution: We use the following methodology:
Step 1: Ten is not an integer power of 2; therefore, we find the largest power of 16 that is less than 100: 160 = 1, 161 = 16, 162
= 256
Step 2: Divide 100 by the largest integer power of 16 and retain the integer This will be the first hexadecimal digit: 100/16 = 6.25 (use 6)
Subtract this from 100, leaving 4
Step 4: Repeat the process until closure: 100 – 96 = 4 Therefore,
Now that we have found the hexadecimal equivalent, we may convert this directly to binary integers one integer at a time: 6416 = 110,0100 Regrouping in threes gives 1,100,100, which converts to
TABLE F.4
Base Equivalents
Base
16 10 20 100 10000
Trang 4612 Modeling of Combustion Systems: A Practical Approach
Clearly, the latter method is easier, but it is only possible if an integer power relates the bases Conversely, because 16, 8, 4, and
2 relate by integer powers, one can convert among them with relative ease
An Apologetic for Octal
In the usual case, humans possess 10 digits, 5 on each hand Our counting system seems to derive from this The linguistic term betrays an association
— we use the term digits to refer to either fingers or numerals Were our
counting system to have ignored thumbs, it may have grown to become octal rather than decimal This would have some advantages First, it is much easier to convert octal to binary or hexadecimal — the arithmetic of
(numbered 0, 1, 2, 3, 4, 5, 6, 7), dividing the work–rest–play cycle evenly And instead of counting only to 10 with our fingers and thumbs, we would
to represent octals The ancient tally system of counting is somewhat closer
to this procedure in the sense that it uses four vertical strokes to represent numbers up to 4 and one cross-stroke for the number 5 This is actually a base 5 system, and it unmistakably resembles the four fingers and one thumb
of the human hand The leap to base 10 (two hands) is not so hard to imagine Considering their love for the number 7, one would have thought that the ancient Hebrews and their predecessors would have preferred octal to dec-imal, since it gives 7 as the largest numeral.* The relationship between a 24-hour day and a 360° rotation of the Earth gives 15° per 24-hour; octal would
bisect So, the Greeks with their love for geometry and integers should have loved such a system An octal world is a world where children never labor
to convert fractional measures; they become trivial: 1/2 = 0.48, 1/4 = 0.28, 1/8
= 0.18, 1/16 = 0.048, 1/32 = 0.028, 1/64 = 0.018, etc Even music with its octave scales and whole, half, quarter, eighth, and sixteenth notes would be better served by an octal system Alas, for all these advantages and ancient possi-bilities, we live in a decimal world, not an octal one But is it too much to hope for change? The metric system has unified and harmonized scores of other units and divisions The French still count by 20s (e.g., 90 is spoken
quatre vingt dix, literally “four 20s, 10”) Perhaps an octal future is not so
far-fetched The author eagerly awaits this brave new world (along with the return of the slide rule, which, by the way, would be easier to construct)