2 /* $OpenBSD: bc.library,v 1.3 2007/02/03 21:15:06 otto Exp $ */
5 * Copyright (C) Caldera International Inc. 2001-2002.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code and documentation must retain the above
12 * copyright notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed or owned by Caldera
20 * 4. Neither the name of Caldera International, Inc. nor the names of other
21 * contributors may be used to endorse or promote products derived from
22 * this software without specific prior written permission.
24 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
25 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT,
29 * INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
34 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
39 * @(#)bc.library 5.1 (Berkeley) 4/17/91
44 auto a, b, c, d, e, g, t, w, y, r
50 if (x > 0) scale = (0.435*x)/1
51 scale = scale + t + length(scale + t) + 1
69 for (a = 1; 1 == 1; a++) {
81 if (w == 1) return (1/g)
89 auto a, b, c, d, e, f, g, u, s, t, r
103 s = length(x) - scale(x)
106 a = (2.31*s)/1 /* estimated integer part of the answer */
107 s = t + length(a) + 2 /* estimated length of the answer */
110 scale = (length(x) + scale(x))/2 + 1
111 if (scale < s) scale = s
117 scale = scale(x)/2 + 1
118 if (scale < s) scale = s
124 scale = t + length(f) + length((1.05*(t+length(f))/1)) + 1
132 for (a = 3; 1 == 1 ; a = a + 2) {
147 auto a, b, c, s, t, y, p, n, i, r
152 s = t + length(y) - scale(y)
158 if (x >= 0) n = (x/(2*p) + 1)/2
159 if (x < 0) n = (x/(2*p) - 1)/2
161 if (n % 2 != 0) x = -x
163 scale = t + length(1.2*t) - scale(1.2*t)
168 for (i =3 ; 1 == 1; i = i + 2) {
194 auto a, b, c, d, e, f, g, s, t, r
195 if (x == 0) return(0)
201 a = .7853981633974483096156608458198757210492923498437764/1
210 x = -(1 - sqrt(1. + x*x))/x
215 x = -(1 - sqrt(1. + x*x))/x
223 for (a = 3; 1 == 1; a = a + 2) {
238 auto a, b, c, d, e, g, i, s, k, t, r
243 k = 1.36*x + 1.16*t - n
244 k = length(k) - scale(k)
245 if (k > 0) scale = scale + k
254 for (i = 1; i <= n; i++) {
261 for (i = 1; 1; i++) {
274 /* vim: set filetype=bc shiftwidth=8 noexpandtab: */