xref: /freebsd/lib/msun/src/e_scalb.c (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1 
2 /* @(#)e_scalb.c 1.3 95/01/18 */
3 /*
4  * ====================================================
5  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6  *
7  * Developed at SunSoft, a Sun Microsystems, Inc. business.
8  * Permission to use, copy, modify, and distribute this
9  * software is freely granted, provided that this notice
10  * is preserved.
11  * ====================================================
12  */
13 
14 #include <sys/cdefs.h>
15 __FBSDID("$FreeBSD$");
16 
17 /*
18  * __ieee754_scalb(x, 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 #ifdef _SCALB_INT
27 double
28 __ieee754_scalb(double x, int fn)
29 #else
30 double
31 __ieee754_scalb(double x, double fn)
32 #endif
33 {
34 #ifdef _SCALB_INT
35 	return scalbn(x,fn);
36 #else
37 	if (isnan(x)||isnan(fn)) return x*fn;
38 	if (!finite(fn)) {
39 	    if(fn>0.0) return x*fn;
40 	    else       return x/(-fn);
41 	}
42 	if (rint(fn)!=fn) return (fn-fn)/(fn-fn);
43 	if ( fn > 65000.0) return scalbn(x, 65000);
44 	if (-fn > 65000.0) return scalbn(x,-65000);
45 	return scalbn(x,(int)fn);
46 #endif
47 }
48