Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precision? #56

Open
TethysSvensson opened this issue Sep 21, 2021 · 3 comments
Open

Precision? #56

TethysSvensson opened this issue Sep 21, 2021 · 3 comments

Comments

@TethysSvensson
Copy link

First of all: Extremely cool project! (Found you on reddit)

I am unsure what the --precision flag does. I tried to running kalker --precision 1000, however kalker did not output what I expected it to. Perhaps the flag is for internal precision only?

My session:

>> x=0.00000000001
>> x
0
>> x * 10
10^-10 ≈ 0

Perhaps this is an error on my part, but I would not have expected kalker to ever show me an exact 0 when the value is in fact non-zero, no matter which precision is chosen.

Additionally I would expect it to be able to output numbers to higher precision thatn 10^-10. That's much lower than even the range of an f32.

@PaddiM8
Copy link
Owner

PaddiM8 commented Sep 21, 2021

Ah yes. The precision flag used to do what you would expect it to do. However, once the web version was made, less focus was put on precision, since the big float library doesn't support WebAssembly. This was supposed to be temporary, while trying to find an appropriate library for big floats with WebAssembly support, but since I haven't been able to find one, this should probably be fixed now.

@PaddiM8
Copy link
Owner

PaddiM8 commented Sep 22, 2021

I now made it so that output values are of the same precision as the precision you specify with the flag, if you explicitly choose one. You lose some eye candy, but now if you specifically need high precision, there is an option for that.

When it comes to normal usage, without the precision flag, it gets a bit complicated, due to floating point errors. Kalker gets around this in some situations by assuming a result like 0.000000000072895 is a floating point error rather than an expected result, since floating point errors like this happens very often, while you don't do calculations on tiny numbers like this as often. It's a trade-off, and not one I'm very comfortable with, but I do really value being able to give the user good readable output. Without this, it would start to show confusing results in other places instead, such as:

>> sin(π)
1.2246467991473531773 * 10^-16
>> 0.1 - 0.2
-0.10000000000000000555

Being able to explicitly say you value precision more now makes it a bit more acceptable, but yeah, I'm still not comfortable with any of these two options. Hm...

@bokeron2020
Copy link

I would really love Kalker woulld offer arbitrary precision. Some other calculators do it but they aren't as user-friendly as Kalker. I don't really understand how they deal with that and floating point errors... but I'm not a programmer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants