e5dfb59b8301094e8ff13ec2a74e20d009581d8f
[dragonfly.git] / lib / msun / src / e_scalbf.c
1 /* e_scalbf.c -- float version of e_scalb.c.
2  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3  *
4  * $FreeBSD: src/lib/msun/src/e_scalbf.c,v 1.5 1999/08/28 00:06:38 peter Exp $
5  * $DragonFly: src/lib/msun/src/Attic/e_scalbf.c,v 1.2 2003/06/17 04:26:53 dillon Exp $
6  */
7
8 /*
9  * ====================================================
10  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
11  *
12  * Developed at SunPro, a Sun Microsystems, Inc. business.
13  * Permission to use, copy, modify, and distribute this
14  * software is freely granted, provided that this notice
15  * is preserved.
16  * ====================================================
17  */
18
19 #include "math.h"
20 #include "math_private.h"
21
22 #ifdef _SCALB_INT
23 #ifdef __STDC__
24         float __ieee754_scalbf(float x, int fn)
25 #else
26         float __ieee754_scalbf(x,fn)
27         float x; int fn;
28 #endif
29 #else
30 #ifdef __STDC__
31         float __ieee754_scalbf(float x, float fn)
32 #else
33         float __ieee754_scalbf(x,fn)
34         float x, fn;
35 #endif
36 #endif
37 {
38 #ifdef _SCALB_INT
39         return scalbnf(x,fn);
40 #else
41         if (isnanf(x)||isnanf(fn)) return x*fn;
42         if (!finitef(fn)) {
43             if(fn>(float)0.0) return x*fn;
44             else       return x/(-fn);
45         }
46         if (rintf(fn)!=fn) return (fn-fn)/(fn-fn);
47         if ( fn > (float)65000.0) return scalbnf(x, 65000);
48         if (-fn > (float)65000.0) return scalbnf(x,-65000);
49         return scalbnf(x,(int)fn);
50 #endif
51 }