
Entry #100045: The SQLBased Calculatorby Stephen Oberholtzer
This is the ultimate nightmare.
For a short description, a line from the README file sums this up: I would not force my own worst enemy to maintain this code. Internally, all values are stored as in a base10 floatingpoint format: a structure containing an array of digits, the sign, and the number of digits before the decimal point. Basically, a string. Over 64K lines (2MB!) of the program is a publicdomain database engine called SQLite. All calculations in the program are done by breaking them down into the following three primitives: 1. Adding two digits and a carry digit. 2. Subtracting two digits and a carry digit. 3. Multiplying two digits and adding a carry digit. These three primitives are themselves implemented by looking them up in an inmemory SQL database that basically maps (digit1, digit2, carry) to (newdigit, newcarry). Addition and subtraction are easy; multiplication is achieved by a combination of singledigit multiplication and addition. Division is achieved by repeated subtraction and manipulation of the decimal point. Like my other "good" entry, the Overkill Calculator, this program is fairly straightforward, with plenty of comments  only the theory behind its implementation is insane. Extremelyinsane. Keep a bucket by your PC in case your brain melts. Download • 0 Comments 