Today, I bring you yet another update to GlassCalc. Version 1.32 can now display output as fractions using an algorithm by John Kennedy described here. To display a result as a fraction, end it with
0.5->frac = 1/2. The
-> operator (for output in fractions and different bases) also has syntax highlighting now.
I got a bug report earlier alerting me that
22.4 - 21.5 resulted in 0.899999999999999. This happens because there are some numbers which cannot be represented exactly as floating point numbers. 22.4 and 0.9 happen to be two of those numbers. (If you don’t believe me, check out this floating point applet and enter “22.4” in the decimal box. GlassCalc has 64 bit precision instead of 32, but the same idea applies.) As a result,
22.4 - 21.5 almost equals 0.9, but not quite.
Unless someone invents a computer that operates in base 10, there’s no way to really fix this problem, but there are a couple ways to hide it. One is to use higher precision floating point numbers to reduce the error, but I can’t do that until I finish porting MTParser to C#. The other is to round results to hide the error in the last decimal place. By default, GlassCalc now rounds to 14 places when displaying numbers. You can change how much GlassCalc rounds (or turn rounding off) from the settings menu. This rounding only applies to the numbers when they are displayed, so your calculations will be just as accurate (or inaccurate) as they were before.
Pi is another number that cannot be represented exactly in floating point. (It can’t be represented exactly in decimal either) As a result,
sin(pi) resulted in very small, but non-zero numbers. I’ve added a couple overrides into cos() and sin() so that they will return exactly 0 when they’re supposed to. Again, this isn’t perfect.
sin(11pi) won’t return exactly 0, but it’s better than nothing.
Other improvements in the version include: smarter detection of changes in extensions.ini, single digit exponents are no longer padded with a zero, saved history no longer forgets the bases of results, and switching between radians and degrees scrolls the history list to the bottom.
Check the GlassCalc page for download links.