2 * $OpenBSD: bc.library,v 1.1 2003/09/25 19:34:22 otto Exp $
3 * $DragonFly: src/usr.bin/bc/bc.library,v 1.1 2004/09/20 04:20:34 dillon 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
49 scale = t + .434*x + 1
86 auto a, b, c, d, e, f, g, u, s, t
87 if(x <=0) return(1-10^scale)
91 scale = scale + scale(x) - length(x) + 1
94 s = s + (length(x)-scale(x))/2 + 1
100 s = s + (length(x)-scale(x))/2 + 1
106 scale = t + length(f) - scale(f) + 1
109 scale = scale + 1.1*length(t) - 1.1*scale(t)
129 auto a, b, c, s, t, y, p, n, i
132 s = t + length(y) - scale(y)
138 if(x>=0) n = (x/(2*p)+1)/2
139 if(x<0) n = (x/(2*p)-1)/2
143 scale = t + length(1.2*t) - scale(1.2*t)
148 for(i=3; 1==1; i=i+2){
152 if(c==0){scale=t; return(s/1)}
167 auto a, b, c, d, e, f, g, s, t
171 return(.7853981633974483096156608458198757210492923498437764/1)
178 x= -(1-sqrt(1.+x*x))/x
183 x = -(1-sqrt(1.+x*x))/x
205 auto a,b,c,d,e,g,i,s,k,t
208 k = 1.36*x + 1.16*t - n
209 k = length(k) - scale(k)
210 if(k>0) scale = scale + k