diff options
-rw-r--r-- | usr.bin/bc/bc.library | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/usr.bin/bc/bc.library b/usr.bin/bc/bc.library index 6a40d60330d..83cc1b4ea8f 100644 --- a/usr.bin/bc/bc.library +++ b/usr.bin/bc/bc.library @@ -1,4 +1,4 @@ -/* $OpenBSD: bc.library,v 1.2 2007/01/29 11:02:53 otto Exp $ */ +/* $OpenBSD: bc.library,v 1.3 2007/02/03 21:15:06 otto Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -40,8 +40,10 @@ scale = 20 define e(x) { - auto a, b, c, d, e, g, t, w, y + auto a, b, c, d, e, g, t, w, y, r + r = ibase + ibase = A t = scale scale = t + .434*x + 1 @@ -72,16 +74,23 @@ define e(x) { g = g*g } scale = t - if (w == 1) return(1/g) - return(g/1) + ibase = r + if (w == 1) return (1/g) + return (g/1) } e = g } } define l(x) { - auto a, b, c, d, e, f, g, u, s, t - if (x <= 0) return (1 - 10^scale) + auto a, b, c, d, e, f, g, u, s, t, r + r = ibase + ibase = A + if (x <= 0) { + a = (1 - 10^scale) + ibase = r + return (a) + } t = scale f = 1 @@ -116,6 +125,7 @@ define l(x) { g = c/d if (g == e) { scale = t + ibase = r return (u*c/d) } e = g @@ -123,7 +133,9 @@ define l(x) { } define s(x) { - auto a, b, c, s, t, y, p, n, i + auto a, b, c, s, t, y, p, n, i, r + r = ibase + ibase = A t = scale y = x/.7853 s = t + length(y) - scale(y) @@ -148,6 +160,7 @@ define s(x) { c = a/b if (c == 0) { scale = t + ibase = r return (s/1) } s = s + c @@ -155,20 +168,28 @@ define s(x) { } define c(x) { - auto t + auto t, r + r = ibase + ibase = A t = scale scale = scale + 1 x = s(x + 2*a(1)) scale = t + ibase = r return (x/1) } define a(x) { - auto a, b, c, d, e, f, g, s, t + auto a, b, c, d, e, f, g, s, t, r if (x == 0) return(0) + + r = ibase + ibase = A if (x == 1) { if (scale < 52) { - return(.7853981633974483096156608458198757210492923498437764/1) + a = .7853981633974483096156608458198757210492923498437764/1 + ibase = r + return (a) } } t = scale @@ -194,6 +215,7 @@ define a(x) { d = d*a g = c/d if (g == e) { + ibase = r scale = t return (x*c/d) } @@ -202,8 +224,10 @@ define a(x) { } define j(n,x) { - auto a,b,c,d,e,g,i,s,k,t + auto a, b, c, d, e, g, i, s, k, t, r + r = ibase + ibase = A t = scale k = 1.36*x + 1.16*t - n k = length(k) - scale(k) @@ -229,6 +253,7 @@ define j(n,x) { c = c*i*(n + i) g = b/c if (g == e) { + ibase = r scale = t return (g/1) } |