Faster binary converter – where do your solutions come from?

Mitch Wheat is a great guy. He really is. And he's clearly a mathematician.

I mean, I did a half-major as part of my BSc, doing a handful of 3rd year Pure Maths subjects (which I got HDs in too – I wasn't just sleeping during class), but Mitch… he thinks like a mathematician. You can tell when he comes up with a solution like this for converting numbers to binary. Makes me wonder if this is something he came up with, or something he read in a book. Knowing Mitch, he came up with it himself. I'm in a bit of awe here. I feel like it's the kind of solution that I could've come up with once upon a time, and hopefully could still given the right colleagues and a whiteboard. 🙂

Let's come back to the 'solution read in a book' thing.

I remember sitting in a user-group meeting in Redmond in March. Itzik was speaking. He was talking about the use of CLR in SQL, and came across the Product aggregate function. There is no product() in T-SQL, and a lot of people have considered that it's a good candidate for CLR, since you can make a user-defined aggregate function this way. Itzik's lines were something like "And I was sure there was a good way of doing this without having to use CLR, so I got reading my maths books." He mentioned some of the names that I have a vague recollection of from my university days (which I have forgotten again so won't write here), and then said that he came across log(a*b) = log(a) + log(b). And of course, almost everyone in the room had light-bulbs appear.

I wasn't so much inspired by the fact that "here's this great way of solving the product question", but rather "here's a way of solving some miscellaneous thing, where the answer comes out of a maths book." And now I've found Mitch providing me with the same hunger to academise (that's not a word, but you know what I mean).

I nearly got into academia. Having done uni, I had offers to do a PhD. But I had a good job offer, and studying didn't seem like it was going to pay the bills. A large part of me would've liked to have done. I remember being a research assistant for Professor John Crossley at Monash, helping to write code (in CAM/L, using a Tcl/Tk interface) to try to convert mathematical proofs into computer programs (the idea being that if you can prove – using really fundamental principles – that for all x, there exists a number y that has particular properties, then that proof should be able to be converted 'automatically' into a program which will find that y). I found that fascinating. I don't know whether the theory ever got really proven, but I found academia really interesting.

And of course, in the 'real' world, the uses of academia are somewhat doubted. It was good to see a locknote session at Tech.Ed (AU) this year about some of the image processing stuff that Microsoft Research Labs are working on. But I'm also really curious to know about algorithms for solving interesting problems.

 

One thought on “Faster binary converter – where do your solutions come from?”

  1. Hi Rob

    Thanks for the kind words! I've used similar techniques in various guises for quite a few years (I've done a fair bit in the way of bit manipulation algorithms and assembler), but it is not a new technique. I can't remember where I first saw something similiar. I suppose it is really just a one-to-one mapping.

Leave a Reply

Your email address will not be published. Required fields are marked *