Re:Data structures and algorithms I actually used while work...
by enriquto on Wednesday July 15, 2020 @05:57AM
(#23843142)
While your formula is correct, it is not an actual implementation. How many digits of the square root do you need to compute exactly for being sure that the value of the power does not change?
Whether this is "fast" or not depends a lot on the concrete implementation of your arbitrary-precision real numbers.
As a nice thing, the second term (after the first minus sign) is smaller than 1, so you can omit it by rounding the result to the nearest integer; all the game happens in the first term.
Whether this is "fast" or not depends a lot on the concrete implementation of your arbitrary-precision real numbers.
As a nice thing, the second term (after the first minus sign) is smaller than 1, so you can omit it by rounding the result to the nearest integer; all the game happens in the first term.