-
Notifications
You must be signed in to change notification settings - Fork 75
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
gcd
shows wrong result when input number is too large
#119
Comments
Hm yeah. Not even sure why this happens. It would make sense to warn the user, but I'm not sure there's a way to do that currently, while still giving a result. If we figure out when exactly this happens, it might make sense to simply return an error if the input is too large (for now at least). It seems to be when both are a certain size, but I haven't found a more specific pattern yet. |
I'd be happy to help or contribute in any way if I can (and have enough time). Could you please point me to where the |
Great! That might speed things up, since I also have limited time right now. The function is implemented here: kalker/kalk/src/prelude/mod.rs Line 612 in 9b55f89
KalkValue represents a value in kalk, usually a number. Normally, this is a heap allocated big float, but for the web version it's just an f64, since the big float library doesn't support WebAssembly. To be able to write generic code despite this, there is a float! macro that turns a number into the relevant type. |
How can kalker/kalk/src/kalk_value/mod.rs Lines 23 to 38 in 9b55f89
I would love to contribute if I understand the issue completely. |
The purpose of |
I believe it has something to do with the fact that Line 22 in e9c9e81
Lines 13 to 30 in e9c9e81
So no matter what you do with float!(), you will always be passing it f64 with less precision and hence value may be different than what it was asked to parse originally. I don't know if I am right on this, but it is a best guess about the source of "error" I could make as a newbie. |
Hm yeah that sounds about right yeah. It should probably be a rug float when the rug feature is enabled. |
I have changed a lot of things in codebase to fix this. Everything compiles and test out just fine with This would parse strings with correct precision instead of loading them into Unfortunately for without |
Actual Behavior
Expected result
Suggestion
I think it would be more helpful to warn a user if the input value is larger than some amount.
And I am willing to contribute or send PR if needed.
Regards.
The text was updated successfully, but these errors were encountered: