Cygwin: SetThreadName: avoid spurious debug message
[newlib-cygwin.git] / newlib / libm / math / s_ldexp.c
blob89ba3d0c022d83e97b4b48fd85a51bbe8dac4e44
2 /* @(#)s_ldexp.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 FUNCTION
16 <<ldexp>>, <<ldexpf>>---load exponent
18 INDEX
19 ldexp
20 INDEX
21 ldexpf
23 SYNOPSIS
24 #include <math.h>
25 double ldexp(double <[val]>, int <[exp]>);
26 float ldexpf(float <[val]>, int <[exp]>);
28 DESCRIPTION
29 <<ldexp>> calculates the value
30 @ifnottex
31 <[val]> times 2 to the power <[exp]>.
32 @end ifnottex
33 @tex
34 $val\times 2^{exp}$.
35 @end tex
36 <<ldexpf>> is identical, save that it takes and returns <<float>>
37 rather than <<double>> values.
39 RETURNS
40 <<ldexp>> returns the calculated value.
42 Underflow and overflow both set <<errno>> to <<ERANGE>>.
43 On underflow, <<ldexp>> and <<ldexpf>> return 0.0.
44 On overflow, <<ldexp>> returns plus or minus <<HUGE_VAL>>.
46 PORTABILITY
47 <<ldexp>> is ANSI. <<ldexpf>> is an extension.
49 */
51 #include "fdlibm.h"
52 #include <errno.h>
54 #ifndef _DOUBLE_IS_32BITS
56 #ifdef __STDC__
57 double ldexp(double value, int exp)
58 #else
59 double ldexp(value, exp)
60 double value; int exp;
61 #endif
63 if(!finite(value)||value==0.0) return value;
64 value = scalbn(value,exp);
65 if(!finite(value)||value==0.0) errno = ERANGE;
66 return value;
69 #endif /* _DOUBLE_IS_32BITS */