When looking to make the world a better place the key is often to find a problem and then come up with the solution to it. With our newly-purchased Android Wear watches we swiftly found that a calculator was a handy little addition to have. Sadly we also noticed that the Android Wear calculators available at the time from the Google Play Store were lacking in functions. Often not offering more than the basic four operators.
So we decided to write a better calculator to supply this gap in the market. Our calculator, dubbed SciCalc, supports many functions including: x cubed, x to the power, inverse, sin, cos, and tan.
Given the small dimensions of the watch display we felt that the most which could reasonably be fitted on the first screen were the basic functions. So we employed a swipe feature to flip over to a separate ‘advanced functions’ screen. Swiping left again would bring back the home screen. The idea was to allow extra pages to be slipped in whilst always using ‘swipe left’, leading to a wrap-around layout rather than the bouncing left-right that some other apps use.
Some of the challenges that I had with building the app included a problem concerning precision in dividing and multiplying. At first I used doubles which caused problems as the calculator would say 3.0000000000001 when it should say 3. This was solved by using BigDecimals. The inaccuracy error would come about because in Java the value 0.1 couldn’t be represented precisely as a double but using BigDecimal meant that it could.
Another problem was that as you cube a number it can become very big and you can easily fill up the amount of digits the screen can hold sensibly, 13 digits. So I had to turn to scientific notation or it wouldn’t be possible to read all of the digits in the number. Sadly, BigDecimal doesn’t have this feature so I had to put in a check for the length of the number and then convert it to a float if it had more than 8 digits. This conversion to a float automatically changed it to use scientific notation.
You can find the SciCalc app in the Google Play Store