-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
math.big.div will hang when the number beyond some value #23806
Comments
Connected to Huly®: V_0.6-22216 |
It depends on If I change it to That constant is used in only one place, like this: const newton_division_limit = 100_000
@[inline]
fn divide_array_by_array(operand_a []u32, operand_b []u32, mut quotient []u32, mut remainder []u32) {
if operand_a.len >= newton_division_limit {
newton_divide_array_by_array(operand_a, operand_b, mut quotient, mut remainder)
} else {
binary_divide_array_by_array(operand_a, operand_b, mut quotient, mut remainder)
}
} i.e. if the first operand length is bigger than the constant, it forces the calculation to use If not, it uses the simpler
|
newton_divide_array_by_array was added in #11487 , with a comment:
|
I tested with bumping the constant to
|
for lastx != x { // main loop
lastx = x
x = (x * (pow2_k_plus_1 - (x * b))).right_shift(u32(k))
} The values for |
Given the divergent loop, perhaps we should just not use I also saw empirically, that I have not done extensive analysis, but given both the performance and correctness drawbacks of |
@VincentLaisney , @hungrybluedev what do you think? |
I've added |
I'm happy to keep binary division and drop newton division. |
It maybe related to multiplication |
Describe the bug
When use big number div, it will hang when the number beyond some value.
Reproduction Steps
big.v
Expected Behavior
Current Behavior
the second run will hang ....
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.9 ab2eb00
Environment details (OS name and version, etc.)
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: