From 28994509cc11ac6a5443054dfae1fedfb69039bc Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 21 Apr 2004 22:19:33 +0000 Subject: Why not? --- src/cmd/map/libmap/cubrt.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/cmd/map/libmap/cubrt.c (limited to 'src/cmd/map/libmap/cubrt.c') diff --git a/src/cmd/map/libmap/cubrt.c b/src/cmd/map/libmap/cubrt.c new file mode 100644 index 00000000..fd508d2b --- /dev/null +++ b/src/cmd/map/libmap/cubrt.c @@ -0,0 +1,30 @@ +#include +#include +#include "map.h" + +double +cubrt(double a) +{ + double x,y,x1; + if(a==0) + return(0.); + y = 1; + if(a<0) { + y = -y; + a = -a; + } + while(a<1) { + a *= 8; + y /= 2; + } + while(a>1) { + a /= 8; + y *= 2; + } + x = 1; + do { + x1 = x; + x = (2*x1+a/(x1*x1))/3; + } while(fabs(x-x1)>10.e-15); + return(x*y); +} -- cgit v1.2.3