Phil Dreizen

some very clever code to print an integer

While reading Microprocessors: A Programmers View, a very old book on different computer architectures, I came across this really clever bit of code for printing out an integer to ascii:

void itoa(unsigned int i){
    if(i >= 10) itoa(i/10);
    putchar('0' + i%10);

(I modified the name of the function, and the style of the parameters)

It's just a really nice example of recursion. (Of course, it appeared in an example about how SPARC's "register window" method of doing procedure calls would potentially perform poorly in code like this (this was in 1990)).


Curiosity killed the cat, but satisfaction brought her back.

Update:I should fill this in a bit. I had been told erroneously, by a friend, that the original expression had always been "Curiosity killed the cat, but satisfaction brought her back" and that the second part was eventually dropped. But it seems to be the case that the "satisfaction brought her back" part is much newer than the more commonly known first part. The etymology of the phrase is that it began as something like "Care killed the cat" in Elizabethan english, where "care" means something like "worry" and changed into "Curiosity" later. The "satisfaction brought her back" is more recent - dating at least as far back as the 1930s.

The meaning and origin of the expression: Curiosity killed the cat