About The Contest

The first ever Olympiad of Misguided Geeks contest at Worse Than Failure (or OMGWTF for short) is a new kind of programming contest. Readers are invited to be creative with devising a calculator with the craziest code they can write. One lucky and potentially insane winner will get either a brand new MacBook Pro or comparable Sony VAIO laptop.



Entry #100043: Buggy 4-Function Calculator

by Stephen Oberholtzer

What makes this special? Well, for one thing, it leaks memory, which is pretty impressive for something that shouldn't need to *allocate* any memory.

For each operator, the first input is converted four times: from string, to float, back to string, to float. The second input is only converted from string to float.

Then each input is converted to a horrible fixed-point format. Computations are performed on this new format, then converted back to float, then converted back to a string for display.

Lots of little WTFs were thrown in, with things like IsNegative, memory leaks, and subtle comments. Also, I'm pretty sure the math is a bit off for certain inputs.

I'm sure I had other things to say, but I completely forgot what it was between my original submission and my resubmission.

Download0 Comments