fix regression from a745c4bfc8a9b5db4e48387170da0dc1d39e3abe
[uclibc-ng.git] / libm / e_scalb.c
blob7e08af232986389d1f45e2be74207458db27a72f
1 /*
2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 * Developed at SunPro, a Sun Microsystems, Inc. business.
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
8 * is preserved.
9 * ====================================================
13 * __ieee754_scalb(x, fn) is provided for
14 * passing various standard test suites.
15 * One should use scalbn() instead.
18 #include "math.h"
19 #include "math_private.h"
20 #include <errno.h>
22 double __ieee754_scalb(double x, double fn)
24 if (isnan(x)||isnan(fn)) return x*fn;
25 if (!isfinite(fn)) {
26 if(fn>0.0) return x*fn;
27 else return x/(-fn);
29 if (rint(fn)!=fn) return (fn-fn)/(fn-fn);
30 if ( fn > 65000.0) return scalbn(x, 65000);
31 if (-fn > 65000.0) return scalbn(x,-65000);
32 return scalbn(x,(int)fn);