tile: add basic support for tilegx
[uclibc-ng.git] / libm / s_ldexp.c
blobbc0f08e9953a4c7ba91824d57c63356e249002a0
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 * ====================================================
12 #include "math.h"
13 #include "math_private.h"
14 #include <errno.h>
16 /* TODO: POSIX says:
18 * "If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
19 * then errno shall be set to [ERANGE]. If the integer expression
20 * (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
21 * floating-point exception shall be raised."
23 * *And it says the same about scalbn*! Thus these two functions
24 * are the same and can be just aliased.
26 * Currently, ldexp tries to be vaguely POSIX compliant while scalbn
27 * does not (it does not set ERRNO).
30 double ldexp(double value, int _exp)
32 if (!isfinite(value) || value == 0.0)
33 return value;
34 value = scalbn(value, _exp);
35 if (!isfinite(value) || value == 0.0)
36 errno = ERANGE;
37 return value;
39 libm_hidden_def(ldexp)