Closed SJS830 closed 4 years ago
That seems very weird. The unit tests check the functionality of sqrt()
on various numbers and it seems to be functioning as expected, even though the I've only checked it on Linux locally and also on macOS in the CI builds. Can some with Windows and MinGW check it out?
@SJS830 It would be helpful if you can also specify which version of Windows and MinGW you tested it on. It would help further if you can also check if using a different version of the same compiler, or using a different compiler, fixes the issue.
The problem shows up when using the single-include header file: in this sqrt
implementation the sqrt_prev
is initiliazed as BigInt sqrt_prev = 0
, if the function parameter num
is a two-digits number sqrt_current
is initialized with 1, and the following loop while (abs(sqrt_current - sqrt_prev) > 1)
never runs thus returning 1.
This is not happening in the tests because the test FunctionsMathTest
is actually linked against a version of math.hpp
where sqrt_prev
is initialized as BigInt sqrt_prev = -1
.
I think this issue can be closed. Running release.sh
on the current master yields a BigInt.hpp
which doesn't have that issue. What remains is to fix the file distributed under release 4.0.0
I've published a new release (v0.5.0-dev) which includes the fix for this.
Details
Calling sqrt() always returns 1, regardless of the number
System info