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.

Navigation

Advertisements

Entry #100218: WtfCalc

by Edwin
Some "features":
* Debug build doesn't work
* Display of numbers larger than 525288 is wrong
* Display of numbers larger than ~20000000 crashes it
* Fractions will only show three digits, and the last can be inaccurate.
* Will eventually crash.
* Doesn't do what you'd expect when not entering just sequences of
* The 'C' button clears the screen and adds to the current number.
Some things to try (--- means a new set of things):
2 / 0 =
1 + 1 =
---
3 / 0 =
1 + 1 =
1 + 1 =
---
1 * 0 =
---
2 * 0 =
1 + 1 =
---
0 * 2 =
---
1 / 7 =
12 / 100 =

Some implementation notes:

Addition is recursive. Subtraction is implemented as recursion, and relies on repeatedly decrementing a negative int eventually getting to 0.

Implements multiplication in terms of division. Division algorithm is repeated subtraction.

String representations for numbers are cached using a system that uses a lot of memory, crashes for numbers that are too high (or too low), and merges numbers that are close together.

Conversion of numbers to string uses an exponential-time recursive algorithm to check whether bits are set, and then does base-10 addition.

There's an overcomplicated barely used template thing (simulating multi-person development)

Operations selection is done using a case that accidentally falls through, which interferes with the 'Err' reporting.

Download0 Comments