2 * $OpenBSD: bc.library,v 1.3 2007/02/03 21:15:06 otto Exp $
3 * $DragonFly: src/usr.bin/bc/bc.library,v 1.2 2007/09/01 18:42:08 pavalos Exp $
7 * Copyright (C) Caldera International Inc. 2001-2002.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code and documentation must retain the above
14 * copyright notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed or owned by Caldera
22 * 4. Neither the name of Caldera International, Inc. nor the names of other
23 * contributors may be used to endorse or promote products derived from
24 * this software without specific prior written permission.
26 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
27 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
28 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 * IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT,
31 * INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
36 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
41 * @(#)bc.library 5.1 (Berkeley) 4/17/91
46 auto a, b, c, d, e, g, t, w, y, r
51 scale = t + .434*x + 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
100 scale = scale + scale(x) - length(x) + 1
103 s = s + (length(x) - scale(x))/2 + 1
109 s = s + (length(x) - scale(x))/2 + 1
115 scale = t + length(f) - scale(f) + 1
118 scale = scale + 1.1*length(t) - 1.1*scale(t)
124 for (a = 3; 1 == 1 ; a = a + 2) {
139 auto a, b, c, s, t, y, p, n, i, r
144 s = t + length(y) - scale(y)
150 if (x >= 0) n = (x/(2*p) + 1)/2
151 if (x < 0) n = (x/(2*p) - 1)/2
153 if (n % 2 != 0) x = -x
155 scale = t + length(1.2*t) - scale(1.2*t)
160 for (i =3 ; 1 == 1; i = i + 2) {
186 auto a, b, c, d, e, f, g, s, t, r
187 if (x == 0) return(0)
193 a = .7853981633974483096156608458198757210492923498437764/1
202 x = -(1 - sqrt(1. + x*x))/x
207 x = -(1 - sqrt(1. + x*x))/x
215 for (a = 3; 1 == 1; a = a + 2) {
230 auto a, b, c, d, e, g, i, s, k, t, r
235 k = 1.36*x + 1.16*t - n
236 k = length(k) - scale(k)
237 if (k > 0) scale = scale + k
246 for (i = 1; i <= n; i++) {
253 for (i = 1; 1; i++) {