vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

w_scalb.c (1294B)


      1 /* @(#)w_scalb.c 5.1 93/09/24 */
      2 /*
      3  * ====================================================
      4  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
      5  *
      6  * Developed at SunPro, a Sun Microsystems, Inc. business.
      7  * Permission to use, copy, modify, and distribute this
      8  * software is freely granted, provided that this notice
      9  * is preserved.
     10  * ====================================================
     11  */
     12 
     13 #ifndef lint
     14 static char rcsid[] = "$FreeBSD: src/lib/msun/src/w_scalb.c,v 1.7 2002/05/28 18:15:04 alfred Exp $";
     15 #endif
     16 
     17 /*
     18  * wrapper scalb(double x, double fn) is provide for
     19  * passing various standard test suite. One
     20  * should use scalbn() instead.
     21  */
     22 
     23 #include "math.h"
     24 #include "math_private.h"
     25 
     26 #include <errno.h>
     27 
     28 #ifdef _SCALB_INT
     29 double
     30 scalb(double x, int fn)		/* wrapper scalb */
     31 #else
     32 double
     33 scalb(double x, double fn)	/* wrapper scalb */
     34 #endif
     35 {
     36 #ifdef _IEEE_LIBM
     37 	return __ieee754_scalb(x,fn);
     38 #else
     39 	double z;
     40 	z = __ieee754_scalb(x,fn);
     41 	if(_LIB_VERSION == _IEEE_) return z;
     42 	if(!(finite(z)||isnan(z))&&finite(x)) {
     43 	    return __kernel_standard(x,(double)fn,32); /* scalb overflow */
     44 	}
     45 	if(z==0.0&&z!=x) {
     46 	    return __kernel_standard(x,(double)fn,33); /* scalb underflow */
     47 	}
     48 #ifndef _SCALB_INT
     49 	if(!finite(fn)) errno = ERANGE;
     50 #endif
     51 	return z;
     52 #endif
     53 }