Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libm / common / s_log2.c
blob724148c5751f00a42361f3dacbf88993a09496a4
1 /* @(#)s_log2.c 5.1 93/09/24 */
2 /* Modification from s_exp10.c Yaakov Selkowitz 2009. */
4 /*
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 * Developed at SunPro, a Sun Microsystems, Inc. business.
9 * Permission to use, copy, modify, and distribute this
10 * software is freely granted, provided that this notice
11 * is preserved.
12 * ====================================================
16 FUNCTION
17 <<log2>>, <<log2f>>---base 2 logarithm
18 INDEX
19 log2
20 INDEX
21 log2f
23 SYNOPSIS
24 #include <math.h>
25 double log2(double <[x]>);
26 float log2f(float <[x]>);
28 DESCRIPTION
29 The <<log2>> functions compute the base-2 logarithm of <[x]>. A domain error
30 occurs if the argument is less than zero. A range error occurs if the
31 argument is zero.
33 The Newlib implementations are not full, intrinisic calculations, but
34 rather are derivatives based on <<log>>. (Accuracy might be slightly off from
35 a direct calculation.) In addition to functions, they are also implemented as
36 macros defined in math.h:
37 . #define log2(x) (log (x) / _M_LN2)
38 . #define log2f(x) (logf (x) / (float) _M_LN2)
39 To use the functions instead, just undefine the macros first.
41 RETURNS
42 The <<log2>> functions return
43 @ifnottex
44 <<log base-2(<[x]>)>>
45 @end ifnottex
46 @tex
47 $log_2(x)$
48 @end tex
49 on success.
50 When <[x]> is zero, the
51 returned value is <<-HUGE_VAL>> and <<errno>> is set to <<ERANGE>>.
52 When <[x]> is negative, the returned value is NaN (not a number) and
53 <<errno>> is set to <<EDOM>>.
55 PORTABILITY
56 C99, POSIX, System V Interface Definition (Issue 6).
60 * wrapper log2(x)
63 #include "fdlibm.h"
64 #if __OBSOLETE_MATH
65 #include <errno.h>
66 #include <math.h>
67 #undef log2
69 #ifndef _DOUBLE_IS_32BITS
71 #ifdef __STDC__
72 double log2(double x) /* wrapper log2 */
73 #else
74 double log2(x) /* wrapper log2 */
75 double x;
76 #endif
78 return (log(x) / M_LN2);
81 #endif /* defined(_DOUBLE_IS_32BITS) */
82 #endif /* __OBSOLETE_MATH */