-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Bug fix] Handle arithmetic overflow in BigDecimal#div
#10628
Conversation
I think the implementation could be much simplerl Just don't use a variable for There are two unrelated reads from the variable:
|
I thought so too, but consider https://play.crystal-lang.org/#/r/auvc |
Oh, right. Taking some more inspiration from https://github.com/akubera/bigdecimal-rs/blob/fc797c302f4947e429cc331febc66fe3c7badc5e/src/lib.rs#L1273 wouldn't be a bad idea. It seems there's actually a lot missing in our implementation. |
I was also thinking this. But it seems out of scope for a bug fix. If there's an open issue to rewrite Do you think the current implementation is sufficient for the bug fix? |
I suppose it's probably fine to merge this as is. But I'd prefer to overhaul the entire method's implementation, not just fix a single bug. There's likely more. |
Personally, I'd prefer for this PR to only handle the bug fix. I haven't had time to dig into |
Well my fear is that this bug fix isn't much of a help. Because it's pretty certain that many other things are broken in that method. Maybe in other methods, too. Hence I'd like a complete overhaul. You should not feel pressured at! Why don't you try things out, see how far you get? You can ask for help here or better in chat. And if you can't get it done, someone else can take over. |
Could we change it from |
The unsigned overflow should already be fixed with the current state of this PR. |
I think this bug fix, while small, still addresses the original issue entirely. I would feel more comfortable merging a small bug fix as my first contribution, to be honest. I don't understand why a That doesn't mean I won't help with the |
Me too. I don't think there's a need to wait to do an entire refactor for possible bugs, if those bugs are yet unknown. And this PR already fixes one of them, while waiting for a refactor won't. |
BigDecimal#div
Closes #10502