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 #100263: jta_calc

by James Ahlborn
As written in the number.h file:

* Encapsulates an arbitrary precision decimal number. This class combines
* the power of arbitrary precision with the speed of table based lookups
* creating the ultimate number class! Additionally, since the lookup tables
* and related constants are contained entirely in the number_constants.h/.cpp
* files, the number base can easily be swapped out. Want to perform math on
* hexidecimal digits? Just create new number_constants.h/.cpp files,
* recompile, and you are in business! You just cannot ask for a more
* powerful number class.

That's right, all math for the calculator is carried out through lookup
tables. This implementation was built for speed, while still following good
design and encapsulation best practices. Standard libraries were used where
available (except for the arithmetic, of course). Unit tests were written and
can be executed for the given test cases. This code is an employers dream
come true!

Caveat, while the Number class supports arbitrary precision, the calculator ui
is driven by float values. Unfortunately, as the ui API was written by a
separate group with less than ideal design requirements, the resulting
calculator implementation cannot use the full power of the Number class
implementation. Appropriate RFE's have been filed with the ui group so that,
hopefully, a 2.0 release will finally unleash the Number class from the bounds
of the float type.

Download0 Comments