## Malarkey NumbersIn a bid to further alienate the economics / politics / finance audience
I've built up over the years, let's talk about the super-fun subject of
Why? Because I hit a mathematical coincidence at work that was both amusing and time-consuming. Here's some simplified background to explain the situation. I'll phrase it in terms of software pointers, but my circumstances actually involved hardware. I was looking at a number that I knew was an index into an array of 4-byte
values. These values happen to be byte-addressable, however, so it's sensible
to also think about them as a byte array. Recall your introductory
programming classes where you learned that for I became confused because I was comparing the indices of nearby array elements in two different contexts — in one, adjacency showed up as ±1 and in the other, adjacency showed up as ±4. My natural suspicion was that the ±1 numbers were the "array index" numbers and the ±4 numbers were the "pointer offset" numbers. Except that didn't make sense, because to scale an array index to a pointer offset you have to multiply by 4, yet the two numbers I was looking at were both the same: 8478. No scaling by 4! How could this be? I suspected there was a bug in the code that generated my information. I'll cut to the punch line. There was no bug, but something else was going on
here. The first set of numbers was displayed in decimal and the second set
of numbers was displayed in hexadecimal (without a leading I did a little math (which I'll now share with you) and realized that there are many such numbers. A friend suggested I seize the opportunity to christen these "malarkey numbers" in honor of a famous misstatement of my last name at an award ceremony several years ago. So, here goes: - Malarkey Number
- A number whose hexadecimal textual representation is identical to the decimal textual representation of the number multiplied by four.
A little analysis leads us to some interesting properties flowing from this definition. Here's an analysis for 4-digit numbers, like I accidentally hit: 4 * (1000*a + 100*b + 10*c + 1*d) = 4096*a + 256*b + 16*c + 1*d 144*b + 24*c + 3*d = 96*a 48*b + 8*c + d = 32*a 32a = 48b + 8c + d, where each of a b c and d ∈ {0 .. 9} A few properties are quickly apparent: There are no malarkey numbers of fewer than than 4 digits (a=0). The first digit (a) is necessarily greater than the second digit (b). The last digit (d) can only be 0 or 8, because all the other terms are multiples of 8. Let d=0 and the expression simplifies to 4a=6b+c, implying c is even. Let d=8 and the expression simplifies to 4a=6b+c+1, implying c is odd. A quick brute-force search (aren't computers wonderful?) confirms these properties and provides the full list of four-digit malarkey numbers, making some latent patterns visible: 0000 1038 1040 2078 2080 2118 2120 3158 3160 3200 4198 4238 4240 5278 5280 5318 5320 6358 6360 6400 7398 7438 7440 8478 8480 8518 8520 9558 9560 9600 Isn't it interesting how they "mostly" come in pairs, 2 apart? Also interestingly, Therefore, the above is the
© Kyle Markley
— Posted 2006-06-22 06:03:01 UTC —
permalink
| ||