SUMMARY When I do ACOS(-1) in radians I should get PI, but the value is wrong when set to 33 digits. KCalc: 3.14159265358979311599796346854419 BC: 3.14159265358979323846264338327950 STEPS TO REPRODUCE 1. Put in scientific mode and configure the number of digits to 33 2. Calculate ACOS of -1 OBSERVED RESULT 3.14159265358979311599796346854419 EXPECTED RESULT 3.14159265358979323846264338327950 SOFTWARE/OS VERSIONS Windows: macOS: Linux/KDE Plasma: OpenSUSE 15.0 (available in About System) KDE Plasma Version: KDE Frameworks Version: Qt Version: ADDITIONAL INFORMATION Note that I'm wearing my Pi Rat shirt which is also correct. My memory of Pi is also more accurate. (I was bored in high school where they had Pi to 40 digits so I memorized it).
Is your KCalc compiled using MPFR dependency? You can find out by using 'ldd' command in Konsole: ldd /usr/bin/kcalc | grep mp This should show both 'libgmp' as well as 'libmpfr'.
Never mind; MPFR support was disabled with https://commits.kde.org/kcalc/9e1dd53d4cda09d2d395dbd5caa9f403d36c9b03
ldd /usr/bin/kcalc | grep mp libgmp.so.10 => /usr/lib64/libgmp.so.10 (0x00007fb0a9875000) libKF5Completion.so.5 => /usr/lib64/libKF5Completion.so.5 (0x00007fb0a09dc000) This is the version supplied by OpenSUSE in their latest up-to-date repository (not the standard repository). According to a friend of mine who developed his own calculator, he says that libgmp has a lot of accuracy bugs so he is using a different library. I can find out which one he uses. His calculator did give the correct answer.
My coworker suggests using libarb instead of libgmp since libgmp cannot guarantee precision. See http://arblib.org He ran into the same issue when he developed his calculator app using libgmp as I ran into with KCalc and he switched to libarb to solve that problem.
I wrote the knumber library that wraps gmp in kcalc. It is definitely in need of some modernization and perhaps arblib is worth looking into as a replacement for it's big number capabilities. I'll look into it!
Add review request https://phabricator.kde.org/D21495.
Git commit 2a05545830fdc9a2fe6a1d249d9eff52c53b7d1f by Christoph Feck, on behalf of Marcelo Mariano. Committed on 23/06/2019 at 10:21. Pushed by cfeck into branch 'master'. Use MPFR in knumber_float in order to improve floating-point precision Related: bug 132158, bug 148357 FIXED-IN: 19.08.0 Differential Revision: https://phabricator.kde.org/D21495 M +8 -0 CMakeLists.txt M +2 -2 knumber/knumber.cpp M +0 -3 knumber/knumber_base.h M +80 -415 knumber/knumber_float.cpp M +14 -8 knumber/knumber_float.h M +8 -1 knumber/knumber_integer.cpp M +3 -2 knumber/tests/CMakeLists.txt https://commits.kde.org/kcalc/2a05545830fdc9a2fe6a1d249d9eff52c53b7d1f