sl@0
|
1 |
/* S_LDEXP.C
|
sl@0
|
2 |
*
|
sl@0
|
3 |
* Portions Copyright (c) 1993-2005 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
4 |
* All rights reserved.
|
sl@0
|
5 |
*/
|
sl@0
|
6 |
|
sl@0
|
7 |
|
sl@0
|
8 |
/* @(#)s_ldexp.c 5.1 93/09/24 */
|
sl@0
|
9 |
/*
|
sl@0
|
10 |
* ====================================================
|
sl@0
|
11 |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
sl@0
|
12 |
*
|
sl@0
|
13 |
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
sl@0
|
14 |
* Permission to use, copy, modify, and distribute this
|
sl@0
|
15 |
* software is freely granted, provided that this notice
|
sl@0
|
16 |
* is preserved.
|
sl@0
|
17 |
* ====================================================
|
sl@0
|
18 |
*/
|
sl@0
|
19 |
|
sl@0
|
20 |
/*
|
sl@0
|
21 |
FUNCTION
|
sl@0
|
22 |
<<ldexp>>, <<ldexpf>>---load exponent
|
sl@0
|
23 |
|
sl@0
|
24 |
INDEX
|
sl@0
|
25 |
ldexp
|
sl@0
|
26 |
INDEX
|
sl@0
|
27 |
ldexpf
|
sl@0
|
28 |
|
sl@0
|
29 |
ANSI_SYNOPSIS
|
sl@0
|
30 |
#include <math.h>
|
sl@0
|
31 |
double ldexp(double <[val]>, int <[exp]>);
|
sl@0
|
32 |
float ldexpf(float <[val]>, int <[exp]>);
|
sl@0
|
33 |
|
sl@0
|
34 |
TRAD_SYNOPSIS
|
sl@0
|
35 |
#include <math.h>
|
sl@0
|
36 |
|
sl@0
|
37 |
double ldexp(<[val]>, <[exp]>)
|
sl@0
|
38 |
double <[val]>;
|
sl@0
|
39 |
int <[exp]>;
|
sl@0
|
40 |
|
sl@0
|
41 |
float ldexpf(<[val]>, <[exp]>)
|
sl@0
|
42 |
float <[val]>;
|
sl@0
|
43 |
int <[exp]>;
|
sl@0
|
44 |
|
sl@0
|
45 |
|
sl@0
|
46 |
DESCRIPTION
|
sl@0
|
47 |
<<ldexp>> calculates the value
|
sl@0
|
48 |
@ifinfo
|
sl@0
|
49 |
<[val]> times 2 to the power <[exp]>.
|
sl@0
|
50 |
@end ifinfo
|
sl@0
|
51 |
@tex
|
sl@0
|
52 |
$val\times 2^{exp}$.
|
sl@0
|
53 |
@end tex
|
sl@0
|
54 |
<<ldexpf>> is identical, save that it takes and returns <<float>>
|
sl@0
|
55 |
rather than <<double>> values.
|
sl@0
|
56 |
|
sl@0
|
57 |
RETURNS
|
sl@0
|
58 |
<<ldexp>> returns the calculated value.
|
sl@0
|
59 |
|
sl@0
|
60 |
Underflow and overflow both set <<errno>> to <<ERANGE>>.
|
sl@0
|
61 |
On underflow, <<ldexp>> and <<ldexpf>> return 0.0.
|
sl@0
|
62 |
On overflow, <<ldexp>> returns plus or minus <<HUGE_VAL>>.
|
sl@0
|
63 |
|
sl@0
|
64 |
PORTABILITY
|
sl@0
|
65 |
<<ldexp>> is ANSI, <<ldexpf>> is an extension.
|
sl@0
|
66 |
|
sl@0
|
67 |
*/
|
sl@0
|
68 |
|
sl@0
|
69 |
#include "FDLIBM.H"
|
sl@0
|
70 |
#include <errno.h>
|
sl@0
|
71 |
|
sl@0
|
72 |
/**
|
sl@0
|
73 |
Get floating-point value from mantissa and exponent.
|
sl@0
|
74 |
Calculates the floating point value corresponding to
|
sl@0
|
75 |
the given mantissa and exponent
|
sl@0
|
76 |
@return Floating-point value equal to value * 2exp.
|
sl@0
|
77 |
@param x Floating point value representing mantissa
|
sl@0
|
78 |
@param exp Integer exponent
|
sl@0
|
79 |
*/
|
sl@0
|
80 |
EXPORT_C double ldexp(double value, int exp) __SOFTFP
|
sl@0
|
81 |
{
|
sl@0
|
82 |
if(!finite(value)||value==0.0) return value;
|
sl@0
|
83 |
value = scalbn(value,exp);
|
sl@0
|
84 |
if(!finite(value)||value==0.0) errno = ERANGE;
|
sl@0
|
85 |
return value;
|
sl@0
|
86 |
}
|