-
Notifications
You must be signed in to change notification settings - Fork 10
Fix a bug: division is slow in some cases #35
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
Fix a bug: division is slow in some cases #35
Conversation
6fa9315 to
f23a22f
Compare
|
New bugs happened. use numext_fixed_uint::U4096;
fn main() {
let a = U4096::from_dec_str("77207453359070457604620928442586248569527320043595348948921733518358535471105").unwrap();
let b = U4096::from_dec_str("115792089237316195423570985008687907853269984665640564039457584007913129639936").unwrap();
let r1 = &a * &a;
println!("{}", r1);
let r2 = r1 % b;
println!("{}", r2);
}thread 'test_state_work' panicked at 'attempt to add with overflow' |
f23a22f to
1c32953
Compare
cfab40d to
1c32953
Compare
|
Build failed with message error[E0425]: cannot find value `of` in this scope
--> C:\Users\mohan\.cargo\git\checkouts\rust-numext-836c791cc312aa11\cfab40d\fixed-uint\src\lib.rs:11:1
|
11 | / numext_constructor::construct_fixed_uints!(
12 | | U128 {
13 | | size = 128,
14 | | },
... |
41 | | },
42 | | );
| |__^ not found in this scope |
|
That is not my fault, no matter I push which commit, travis ci always run a wrong commit. I have passed all test in my laptop. |
…if the higher unit was reduced to zero after subtraction.
1c32953 to
f898c84
Compare
|
The difference between commit-1c32953b and commit-f898c84 is nothing. But commit-1c32953b failed in clippy, and commit-f898c84 passed. Just a bug of Travis CI. |
…imated quotient is too small each time, led to an overflow.
mohanson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works fine in my test cases now.
Fix bug: in division, when borrow a higher unit, do not forget check if the higher unit was reduced to zero after subtraction.
The reason was written in this comment.
Fix bug: in division, when doing estimate is too cautious, so the estimated quotient is too small each time, led to an overflow.
The reason was written in this comment.