The successive weights of my littlest are, in ounces, `7_{16}12, 7_{16}8, 8_{16}0, 8_{16}8.` These have been written in the wiggle version of base `16`, so that they can be read easily as pounds and ounces.
Computer hardware uses lots of binary---but binary is written out with long strings of ones and zeroes, and that can be a little painful to read.
In a previous post, we saw that taking two decimal digits at a time gives us base `100`, and taking three at a time is base 1000. Taking two binary digits (bits) at a time is base `4`, or quaternary. It is hardly used. Taking three bits at a time is base `8`, or octal. Octal used to be common enough, but is now only occasionally seen: the only current example I can think of is how file permissions are handled in Linux.
Taking four bits at a time is base `16`, called hexadecimal, or hex to its friends.
Those (relatively few) programmers who work "close to the metal" sometimes have cause to examine binary data. They almost never look at actual binary, however. What they read is the binary converted to hexadecimal. Such a listing is called a hex dump.
The usual notation for base `n` arithmetic differs is two ways from the wiggle notation we have been using.
First, there is only a common base, and it is written just once at the end of the string of digits. In the usual notation, bases are always written in decimal. (In wiggle, interbases and superdigits are always written in decimal.) So the usual way to write the bit sequence, or bitstring `10101001010`, explicitly indicating that it is in base 2, is `10101001010_{2}`. If the base is obvious in context, we don't always bother with the subscript. In wiggle, this would be the much longer
`\qquad\qquad\qquad 1_{2}0_{2}1_{2}0_{2}1_{2}0_{2}0_{2}1_{2}0_{2}1_{2}0.`
To convert binary to octal, one groups the binary digits three at a time from the right,
`\qquad\qquad\qquad 10,101,001,010,`
and then converts each three bit binary group to a corresponding octal digit,
`\qquad\qquad\qquad 2512_{8}.`
Second, since the usual notation puts digits next to each other, it has to employ a single character per digit. The usual digits work for bases up to ten. After that, once must have new symbols. Consider, now the hexadecimal number `7_{16}12`, as written in wiggle. We cannot simply write this as `712_{16}`, because we cannot tell whether that means `7_{16}12` or `7_{16}1_{16}2`. Instead, the usual thing to do is to let A mean 10, B mean 11, C mean 12, and so forth, up to one less than the base.
So, instead of `7_{16}12`, one writes `7"C"_{16}`.
To convert binary to hexadecimal, one groups the binary digits four at a time, from the right,
`\qquad\qquad\qquad 101,0100,1010,`
and then converts each four bit binary group into a hexadecimal digit,
`\qquad\qquad\qquad 54"C"_{16}.`
In hexadecimal, my littlest's birthweight was `7"C"` ounces, or, moving the unit point one place, `7."C"` pounds.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment