infnan() in sqrt() and drem(); ifdef out those finite and (x!=x)'s.
SCCS-vsn: lib/libm/common/atan2.c 1.5
SCCS-vsn: lib/libm/ieee/cabs.c 1.5
SCCS-vsn: lib/libm/common/trig.c 1.5
SCCS-vsn: lib/libm/ieee/support.c 1.9
#ifndef lint
static char sccsid[] =
#ifndef lint
static char sccsid[] =
-"@(#)atan2.c 1.3 (Berkeley) 8/21/85; 1.4 (ucb.elefunt) %G%";
+"@(#)atan2.c 1.3 (Berkeley) 8/21/85; 1.5 (ucb.elefunt) %G%";
#endif not lint
/* ATAN2(Y,X)
#endif not lint
/* ATAN2(Y,X)
double copysign(),logb(),scalb(),t,z,signy,signx,hi,lo;
int finite(), k,m;
double copysign(),logb(),scalb(),t,z,signy,signx,hi,lo;
int finite(), k,m;
+#if (!defined(VAX)&&!defined(TAHOE))
/* if x or y is NAN */
if(x!=x) return(x); if(y!=y) return(y);
/* if x or y is NAN */
if(x!=x) return(x); if(y!=y) return(y);
/* copy down the sign of y and x */
signy = copysign(one,y) ;
/* copy down the sign of y and x */
signy = copysign(one,y) ;
/* when x = 0 */
if(x==zero) return(copysign(PIo2,signy));
/* when x = 0 */
if(x==zero) return(copysign(PIo2,signy));
+#if (!defined(VAX)&&!defined(TAHOE))
/* when x is INF */
if(!finite(x))
if(!finite(y))
/* when x is INF */
if(!finite(x))
if(!finite(y))
/* when y is INF */
if(!finite(y)) return(copysign(PIo2,signy));
/* when y is INF */
if(!finite(y)) return(copysign(PIo2,signy));
/* compute y/x */
x=copysign(x,one);
/* compute y/x */
x=copysign(x,one);
#ifndef lint
static char sccsid[] =
#ifndef lint
static char sccsid[] =
-"@(#)trig.c 1.2 (Berkeley) 8/22/85; 1.4 (ucb.elefunt) %G%";
+"@(#)trig.c 1.2 (Berkeley) 8/22/85; 1.5 (ucb.elefunt) %G%";
#endif not lint
/* SIN(X), COS(X), TAN(X)
#endif not lint
/* SIN(X), COS(X), TAN(X)
double x;
{
double copysign(),drem(),cos__C(),sin__S(),a,z,ss,cc,c;
double x;
{
double copysign(),drem(),cos__C(),sin__S(),a,z,ss,cc,c;
+ int k;
+#if (!defined(VAX)&&!defined(TAHOE))
+ extern int finite();
/* tan(NaN) and tan(INF) must be NaN */
if(!finite(x)) return(x-x);
/* tan(NaN) and tan(INF) must be NaN */
if(!finite(x)) return(x-x);
x=drem(x,PI); /* reduce x into [-PI/2, PI/2] */
a=copysign(x,one); /* ... = abs(x) */
if ( a >= PIo4 ) {k=1; x = copysign( PIo2 - a , x ); }
x=drem(x,PI); /* reduce x into [-PI/2, PI/2] */
a=copysign(x,one); /* ... = abs(x) */
if ( a >= PIo4 ) {k=1; x = copysign( PIo2 - a , x ); }
double x;
{
double copysign(),drem(),sin__S(),cos__C(),a,c,z;
double x;
{
double copysign(),drem(),sin__S(),cos__C(),a,c,z;
+#if (!defined(VAX)&&!defined(TAHOE))
+ extern int finite();
/* sin(NaN) and sin(INF) must be NaN */
if(!finite(x)) return(x-x);
/* sin(NaN) and sin(INF) must be NaN */
if(!finite(x)) return(x-x);
x=drem(x,PI2); /* reduce x into [-PI, PI] */
a=copysign(x,one);
if( a >= PIo4 ) {
x=drem(x,PI2); /* reduce x into [-PI, PI] */
a=copysign(x,one);
if( a >= PIo4 ) {
double x;
{
double copysign(),drem(),sin__S(),cos__C(),a,c,z,s=1.0;
double x;
{
double copysign(),drem(),sin__S(),cos__C(),a,c,z,s=1.0;
+#if (!defined(VAX)&&!defined(TAHOE))
+ extern int finite();
/* cos(NaN) and cos(INF) must be NaN */
if(!finite(x)) return(x-x);
/* cos(NaN) and cos(INF) must be NaN */
if(!finite(x)) return(x-x);
x=drem(x,PI2); /* reduce x into [-PI, PI] */
a=copysign(x,one);
if ( a >= PIo4 ) {
x=drem(x,PI2); /* reduce x into [-PI, PI] */
a=copysign(x,one);
if ( a >= PIo4 ) {
#ifndef lint
static char sccsid[] =
#ifndef lint
static char sccsid[] =
-"@(#)cabs.c 1.2 (Berkeley) 8/21/85; 1.4 (ucb.elefunt) %G%";
+"@(#)cabs.c 1.2 (Berkeley) 8/21/85; 1.5 (ucb.elefunt) %G%";
#endif not lint
/* CABS(Z)
#endif not lint
/* CABS(Z)
double copysign(),scalb(),logb(),sqrt(),t,r;
int finite(), exp;
double copysign(),scalb(),logb(),sqrt(),t,r;
int finite(), exp;
+#if (!defined(VAX)&&!defined(TAHOE))
if(finite(x))
if(finite(y))
{
if(finite(x))
if(finite(y))
{
x=copysign(x,one);
y=copysign(y,one);
if(y > x)
x=copysign(x,one);
y=copysign(y,one);
if(y > x)
+#if (!defined(VAX)&&!defined(TAHOE))
}
else if(y==y) /* y is +-INF */
}
else if(y==y) /* y is +-INF */
return(x); /* x is NaN, y is finite */
else if(y!=y) return(y); /* x and y is NaN */
else return(copysign(y,one)); /* y is INF */
return(x); /* x is NaN, y is finite */
else if(y!=y) return(y); /* x and y is NaN */
else return(copysign(y,one)); /* y is INF */
}
/* A faster but less accurate version of cabs(x,y) */
}
/* A faster but less accurate version of cabs(x,y) */
#ifndef lint
static char sccsid[] =
#ifndef lint
static char sccsid[] =
-"@(#)support.c 1.1 (Berkeley) 5/23/85; 1.8 (ucb.elefunt) %G%";
+"@(#)support.c 1.1 (Berkeley) 5/23/85; 1.9 (ucb.elefunt) %G%";
- * Some IEEE standard p754 recommended functions and remainder and sqrt for
+ * Some IEEE standard 754 recommended functions and remainder and sqrt for
* supporting the C elementary functions.
******************************************************************************
* WARNING:
* supporting the C elementary functions.
******************************************************************************
* WARNING:
* its own assembler.
******************************************************************************
*
* its own assembler.
******************************************************************************
*
- * IEEE p754 required operations:
+ * IEEE 754 required operations:
* drem(x,p)
* returns x REM y = x - [x/y]*y , where [x/y] is the integer
* nearest x/y; in half way case, choose the even one.
* drem(x,p)
* returns x REM y = x - [x/y]*y , where [x/y] is the integer
* nearest x/y; in half way case, choose the even one.
* returns the square root of x correctly rounded according to
* the rounding mod.
*
* returns the square root of x correctly rounded according to
* the rounding mod.
*
- * IEEE p754 recommended functions:
+ * IEEE 754 recommended functions:
* (a) copysign(x,y)
* returns x with the sign of y.
* (b) scalb(x,N)
* (a) copysign(x,y)
* returns x with the sign of y.
* (b) scalb(x,N)
#if (defined(VAX)||defined(TAHOE)) /* VAX D format */
#if (defined(VAX)||defined(TAHOE)) /* VAX D format */
static unsigned short msign=0x7fff , mexp =0x7f80 ;
static short prep1=57, gap=7, bias=129 ;
static double novf=1.7E38, nunf=3.0E-39, zero=0.0 ;
static unsigned short msign=0x7fff , mexp =0x7f80 ;
static short prep1=57, gap=7, bias=129 ;
static double novf=1.7E38, nunf=3.0E-39, zero=0.0 ;
#if (defined(VAX)||defined(TAHOE))
if( (k= *px & mexp ) != ~msign ) {
#if (defined(VAX)||defined(TAHOE))
if( (k= *px & mexp ) != ~msign ) {
- if( N<-260) return(nunf*nunf); else if(N>260) return(novf+novf);
+ if (N < -260)
+ return(nunf*nunf);
+ else if (N > 260) {
+ extern double infnan(),copysign();
+ return(copysign(infnan(ERANGE),x));
+ }
#else /* IEEE */
if( (k= *px & mexp ) != mexp ) {
if( N<-2100) return(nunf*nunf); else if(N>2100) return(novf+novf);
#else /* IEEE */
if( (k= *px & mexp ) != mexp ) {
if( N<-2100) return(nunf*nunf); else if(N>2100) return(novf+novf);
double x;
{
#if (defined(VAX)||defined(TAHOE))
double x;
{
#if (defined(VAX)||defined(TAHOE))
#else /* IEEE */
#ifdef NATIONAL
return( (*((short *) &x+3 ) & mexp ) != mexp );
#else /* IEEE */
#ifdef NATIONAL
return( (*((short *) &x+3 ) & mexp ) != mexp );
*pp &= msign ;
#if (defined(VAX)||defined(TAHOE))
*pp &= msign ;
#if (defined(VAX)||defined(TAHOE))
- if( ( *px & mexp ) == ~msign )
+ if( ( *px & mexp ) == ~msign ) /* is x a reserved operand? */
#else /* IEEE */
if( ( *px & mexp ) == mexp )
#endif
return (x-p)-(x-p); /* create nan if x is inf */
#else /* IEEE */
if( ( *px & mexp ) == mexp )
#endif
return (x-p)-(x-p); /* create nan if x is inf */
- if(p==zero) return zero/zero;
#if (defined(VAX)||defined(TAHOE))
#if (defined(VAX)||defined(TAHOE))
- if( ( *pp & mexp ) == ~msign )
+ extern double infnan();
+ return(infnan(EDOM));
+#else
+ return zero/zero;
+#endif
+ }
+
+#if (defined(VAX)||defined(TAHOE))
+ if( ( *pp & mexp ) == ~msign ) /* is p a reserved operand? */
#else /* IEEE */
if( ( *pp & mexp ) == mexp )
#endif
#else /* IEEE */
if( ( *pp & mexp ) == mexp )
#endif
if(x!=x||x==zero) return(x);
/* sqrt(negative) is invalid */
if(x!=x||x==zero) return(x);
/* sqrt(negative) is invalid */
- if(x<zero) return(zero/zero);
+ if(x<zero) {
+#if (defined(VAX)||defined(TAHOE))
+ extern double infnan();
+ return (infnan(EDOM)); /* NaN */
+#else /* IEEE double */
+ return(zero/zero);
+#endif
+ }
/* sqrt(INF) is INF */
if(!finite(x)) return(x);
/* sqrt(INF) is INF */
if(!finite(x)) return(x);