X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/95f51977ddc18faa2e212f30c00a39540b39f325..ca67e7b465996afb3821d6a075c4dc6a7f0f5d52:/usr/src/usr.lib/libm/expm1.c diff --git a/usr/src/usr.lib/libm/expm1.c b/usr/src/usr.lib/libm/expm1.c index 86eacbe7ce..347a41edff 100644 --- a/usr/src/usr.lib/libm/expm1.c +++ b/usr/src/usr.lib/libm/expm1.c @@ -1,19 +1,28 @@ -/* +/* * Copyright (c) 1985 Regents of the University of California. - * - * Use and reproduction of this software are granted in accordance with - * the terms and conditions specified in the Berkeley Software License - * Agreement (in particular, this entails acknowledgement of the programs' - * source, and inclusion of this notice) with the additional understanding - * that all recipients should regard themselves as participants in an - * ongoing research project and hence should feel obligated to report - * their experiences (good or bad) with these elementary function codes, - * using "sendbug 4bsd-bugs@BERKELEY", to the authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * All recipients should regard themselves as participants in an ongoing + * research project and hence should feel obligated to report their + * experiences (good or bad) with these elementary function codes, using + * the sendbug(8) program, to the authors. */ #ifndef lint -static char sccsid[] = "@(#)expm1.c 1.2 (Berkeley) 8/21/85"; -#endif not lint +static char sccsid[] = "@(#)expm1.c 5.3 (Berkeley) 6/30/88"; +#endif /* not lint */ /* EXPM1(X) * RETURN THE EXPONENTIAL OF X MINUS ONE @@ -66,42 +75,47 @@ static char sccsid[] = "@(#)expm1.c 1.2 (Berkeley) 8/21/85"; * shown. */ -#ifdef VAX /* VAX D format */ -/* double static */ +#if defined(vax)||defined(tahoe) /* VAX D format */ +#ifdef vax +#define _0x(A,B) 0x/**/A/**/B +#else /* vax */ +#define _0x(A,B) 0x/**/B/**/A +#endif /* vax */ +/* static double */ /* ln2hi = 6.9314718055829871446E-1 , Hex 2^ 0 * .B17217F7D00000 */ /* ln2lo = 1.6465949582897081279E-12 , Hex 2^-39 * .E7BCD5E4F1D9CC */ /* lnhuge = 9.4961163736712506989E1 , Hex 2^ 7 * .BDEC1DA73E9010 */ /* invln2 = 1.4426950408889634148E0 ; Hex 2^ 1 * .B8AA3B295C17F1 */ -static long ln2hix[] = { 0x72174031, 0x0000f7d0}; -static long ln2lox[] = { 0xbcd52ce7, 0xd9cce4f1}; -static long lnhugex[] = { 0xec1d43bd, 0x9010a73e}; -static long invln2x[] = { 0xaa3b40b8, 0x17f1295c}; +static long ln2hix[] = { _0x(7217,4031), _0x(0000,f7d0)}; +static long ln2lox[] = { _0x(bcd5,2ce7), _0x(d9cc,e4f1)}; +static long lnhugex[] = { _0x(ec1d,43bd), _0x(9010,a73e)}; +static long invln2x[] = { _0x(aa3b,40b8), _0x(17f1,295c)}; #define ln2hi (*(double*)ln2hix) #define ln2lo (*(double*)ln2lox) #define lnhuge (*(double*)lnhugex) #define invln2 (*(double*)invln2x) -#else /* IEEE double */ -double static +#else /* defined(vax)||defined(tahoe) */ +static double ln2hi = 6.9314718036912381649E-1 , /*Hex 2^ -1 * 1.62E42FEE00000 */ ln2lo = 1.9082149292705877000E-10 , /*Hex 2^-33 * 1.A39EF35793C76 */ lnhuge = 7.1602103751842355450E2 , /*Hex 2^ 9 * 1.6602B15B7ECF2 */ invln2 = 1.4426950408889633870E0 ; /*Hex 2^ 0 * 1.71547652B82FE */ -#endif +#endif /* defined(vax)||defined(tahoe) */ double expm1(x) double x; { - double static one=1.0, half=1.0/2.0; + static double one=1.0, half=1.0/2.0; double scalb(), copysign(), exp__E(), z,hi,lo,c; int k,finite(); -#ifdef VAX +#if defined(vax)||defined(tahoe) static prec=56; -#else /* IEEE double */ +#else /* defined(vax)||defined(tahoe) */ static prec=53; -#endif -#ifndef VAX +#endif /* defined(vax)||defined(tahoe) */ +#if !defined(vax)&&!defined(tahoe) if(x!=x) return(x); /* x is NaN */ -#endif +#endif /* !defined(vax)&&!defined(tahoe) */ if( x <= lnhuge ) { if( x >= -40.0 ) {