summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cbrt.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/cbrt.c b/src/cbrt.c
index f327a2dea..58a35681a 100644
--- a/src/cbrt.c
+++ b/src/cbrt.c
@@ -23,26 +23,26 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#define MPFR_NEED_LONGLONG_H
#include "mpfr-impl.h"
- /* The computation of y = x^(1/3) is done as follows:
+/* The computation of y = x^(1/3) is done as follows:
- Let x = sign * m * 2^(3*e) where m is an integer >= 2^(3n-3) with
- n = PREC(y), i.e. m has at least 3n-2 bits.
+ Let x = sign * m * 2^(3*e) where m is an integer >= 2^(3n-3) with
+ n = PREC(y), i.e. m has at least 3n-2 bits.
- Let s be the integer cube root of m, i.e. the maximum integer such that
- m = s^3 + r with r >= 0.
+ Let s be the integer cube root of m, i.e. the maximum integer such that
+ m = s^3 + t with t >= 0.
- The constraint m >= 2^(3n-3) allows one to have sufficient precision
- for s: s >= 2^(n-1), i.e. s has at least n bits.
+ The constraint m >= 2^(3n-3) allows one to have sufficient precision
+ for s: s >= 2^(n-1), i.e. s has at least n bits.
- FIXME: The description below is incorrect if s has more than n bits
- (since n is the target precision).
+ FIXME: The description below is incorrect if s has more than n bits
+ (since n is the target precision).
- Then x^(1/3) = s * 2^e if r=0
- x^(1/3) = (s+1) * 2^e if round up
- x^(1/3) = (s-1) * 2^e if round down
- x^(1/3) = s * 2^e if nearest and r < 3/2*s^2+3/4*s+1/8
- (s+1) * 2^e otherwise
- */
+ Then x^(1/3) = s * 2^e if t = 0
+ x^(1/3) = (s+1) * 2^e if round up
+ x^(1/3) = (s-1) * 2^e if round down
+ x^(1/3) = s * 2^e if nearest and t < 3/2*s^2+3/4*s+1/8
+ (s+1) * 2^e otherwise
+*/
int
mpfr_cbrt (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode)