source: trunk/libs/newlib/src/newlib/libm/math/s_ldexp.c @ 567

Last change on this file since 567 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.5 KB
Line 
1
2/* @(#)s_ldexp.c 5.1 93/09/24 */
3/*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 *
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 * ====================================================
12 */
13
14/*
15FUNCTION
16       <<ldexp>>, <<ldexpf>>---load exponent
17
18INDEX
19        ldexp
20INDEX
21        ldexpf
22
23SYNOPSIS
24       #include <math.h>
25       double ldexp(double <[val]>, int <[exp]>);
26       float ldexpf(float <[val]>, int <[exp]>);
27
28DESCRIPTION
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>>
37rather than <<double>> values.
38
39RETURNS
40<<ldexp>> returns the calculated value.
41
42Underflow and overflow both set <<errno>> to <<ERANGE>>.
43On underflow, <<ldexp>> and <<ldexpf>> return 0.0.
44On overflow, <<ldexp>> returns plus or minus <<HUGE_VAL>>.
45
46PORTABILITY
47<<ldexp>> is ANSI. <<ldexpf>> is an extension.
48             
49*/   
50
51#include "fdlibm.h"
52#include <errno.h>
53
54#ifndef _DOUBLE_IS_32BITS
55
56#ifdef __STDC__
57        double ldexp(double value, int exp)
58#else
59        double ldexp(value, exp)
60        double value; int exp;
61#endif
62{
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;
67}
68
69#endif /* _DOUBLE_IS_32BITS */
Note: See TracBrowser for help on using the repository browser.