Home> urticator.net Search About This Site > Domains Glue Stories Computers Driving Games Humor Law Math > Numbers Science Powers and Fractions Notes About Squares Decimal Expansions Repeat Length Again Number Maze Primes Divisibility Intrinsic Nature of Primes > Other Topics Other Topics (2) Duodecimal Hexadecimal Base 60
Negative Digits Two Kinds of Odd 
OperationsIn Machine Language, I used but didn't explain the word “opcode”. It's short for “operation code”, meaning, a code (number) that refers to one of the fundamental operations the processor can perform. That's the kind of operation I want to talk about here.But, I don't want to talk about operations in the context of processors; I want to apply the analogy between minds and computers, and talk about operations in the context of minds. That's exactly what the category The Mind was meant to contain; I see now that I even referred to “different kinds of operations”. The operations I'll describe here are only a small subset of all the things the mind can do, but they're an interesting and computerlike subset: arithmetic operations. You probably don't think of your mind as having fundamental arithmetic operations, but really it does. Can you add two digits? Subtract them? Multiply them? That's exactly what I'm talking about. The operations aren't built in, of course; you have to learn them in school; but that doesn't make them any less fundamental and atomic. If I ask you to work out 4 + 7, there's no intermediate step you can point to, you just know the answer. Did you notice that I didn't mention division? That was intentional … division is not fundamental and atomic. Just think about long division for a second. It's obviously not atomic; in fact it's obviously a little program you run, just some multiplication and subtraction plus some comparison, branching, and looping. As long as I'm making the analogy to processors, here's one more thing. If you want to do long division, or any other kind of arithmetic, entirely in your head, you'd probably like to have a bunch of internal registers available. Unfortunately, the mind doesn't work that way … at least, mine doesn't. I've done a lot of mental arithmetic, and, at times, intentionally tried to create registers, but I've never been able to do it. I can remember two or even three multidigit numbers, but I still misremember digits, and transpose them, and swap them individually and in groups between different numbers. Sometimes I completely forget a number I'm working with, and have to run through the same calculation several times before I can remember the result. Mental arithmetic is a good way to pass the time on airplanes, by the way. The way I figure it, I'm running up against the limits of shortterm memory … which reminds me of a funny story. I assume you've heard that shortterm memory can hold seven items. Once, in college, I took a psychology class; and as part of the class, we were required to participate in studies. By chance, I ended up in a study on shortterm memory, where I was pleased, and the researchers perhaps annoyed, to discover that I could remember maybe ten or eleven items. That's a small part of why I say the idea that all minds are identical is a fallacy. But I digress. The point I want to come back to is, the mind has fundamental arithmetic operations that are learned rather than built in. The three operations I mentioned are a complete set (I think)—if you know them, and have a pen and paper handy as external memory, you can perform any arithmetical calculation you desire. That completeness, however, makes it easy to overlook something: we learned those three operations, so there's no reason we can't learn other operations as well. (Although, if your mind has fossilized, it will be harder.) The other operations will be redundant, of course, but there's no harm in that. They might be optimizations for special cases, or they might implement as atomic operations things that previously required running a little program. You could learn modular arithmetic, for example, or what's almost the same thing, learn to compute in another base. And, even if the operations were nothing but redundant, there would still be value in that, because they would provide independent methods of producing the same results. Being able to doublecheck your results is always good. The second possibility I mentioned above, implementing programs as atomic operations, is more common than you might think. If you perform any composite operation over and over, you naturally create or strengthen the association between the arguments and the results. That's one thing the mind does very well! Eventually the association will become strong enough that you don't even need to perform the operation, you just know the result … and then the operation is atomic. In computer terms, it's as if every (stateless) function was wrapped inside a hashtable cache of previous results. Actually, there doesn't need to be a composite operation first, you can build an atomic operation out of pure association. That's exactly how one learns to add, subtract, and multiply. That was a longer introduction than I expected, but now at last we come to the original point of this essay, which is that I'm going to describe some real, useful operations that I actually know. Some of them will seem specific to computers, to hexadecimal or binary, but they really are useful in any base.
There's another thing about complements that I ought to point out, which is that they're useful not only within calculations, as above, but also as a way of representing negative numbers. For example, if I know that I'll be working with fivedigit numbers, I can represent 674 as the second complement of 674, to five places, which we already know is 99326. Then, if I want to add 13429 and 674, I can just add their representations 13429 and 99326, and everything works out as it should—I don't have to worry whether either of them is negative. Computers represent negative numbers in exactly this way. The only trick is, the computer knows that it will be working with a certain number of binary digits, so the complements have to be done in binary. So, each digit d is replaced by 1d, or by 2d for the last digit of a second complement. For example, the number 45 in binary is 101101, so the representation of 45 as a byte is 11010011. When the operations are done in binary, the first complement is actually called the ones complement, and the second, twos complement, I think because of that “2” in “2d”. I made up the other names because I thought it didn't make sense to talk about a twos complement in base 10.
I forgot to mention that a left shift can be used as an efficient way of dividing by 5. The idea is, dividing by 5 is the same as multiplying by 2 and then dividing by 10; and the latter is trivial. Then, as a minor optimization, you can handle the last digit separately. If it's zero, you just double the rest; if it's five, you double the rest and add one. For example,
145 / 5 = 2×14 + 1 = 29. Similarly, a right shift can be used as an efficient way of multiplying by 5.

See AlsoAlgorithm, The Complementary Parts Dead Reckoning Euclidean Algorithm, The Fractions Fractions in Base 2 Hexadecimal History and Other Stuff Multiplication Negative Digits Next Block, The Practical Application Primitives Reduction Rules Square Roots Standard Series, The Usual Random Thoughts, The What Is Memorable? @ March (2004) o November (2004) 