2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / java / lang / e_scalb.c
blob0bb924b43ee17c03164f8276235e368e60a163f8
2 /* @(#)e_scalb.c 5.1 93/09/24 */
3 /*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunPro, 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 * ====================================================
15 * __ieee754_scalb(x, fn) is provide for
16 * passing various standard test suite. One
17 * should use scalbn() instead.
20 #include "fdlibm.h"
22 #ifndef _DOUBLE_IS_32BITS
24 #ifdef _SCALB_INT
25 #ifdef __STDC__
26 double __ieee754_scalb(double x, int fn)
27 #else
28 double __ieee754_scalb(x,fn)
29 double x; int fn;
30 #endif
31 #else
32 #ifdef __STDC__
33 double __ieee754_scalb(double x, double fn)
34 #else
35 double __ieee754_scalb(x,fn)
36 double x, fn;
37 #endif
38 #endif
40 #ifdef _SCALB_INT
41 return scalbn(x,fn);
42 #else
43 if (isnan(x)||isnan(fn)) return x*fn;
44 if (!finite(fn)) {
45 if(fn>0.0) return x*fn;
46 else return x/(-fn);
48 if (rint(fn)!=fn) return (fn-fn)/(fn-fn);
49 if ( fn > 65000.0) return scalbn(x, 65000);
50 if (-fn > 65000.0) return scalbn(x,-65000);
51 return scalbn(x,(int)fn);
52 #endif
55 #endif /* defined(_DOUBLE_IS_32BITS) */