1 /* @(#)s_log2.c 5.1 93/09/24 */
2 /* Modification from s_exp10.c Yaakov Selkowitz 2009. */
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
12 * ====================================================
17 <<log2>>, <<log2f>>---base 2 logarithm
25 double log2(double <[x]>);
26 float log2f(float <[x]>);
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
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.
42 The <<log2>> functions return
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>>.
56 C99, POSIX, System V Interface Definition (Issue 6).
69 #ifndef _DOUBLE_IS_32BITS
72 double log2(double x
) /* wrapper log2 */
74 double log2(x
) /* wrapper log2 */
78 return (log(x
) / M_LN2
);
81 #endif /* defined(_DOUBLE_IS_32BITS) */
82 #endif /* __OBSOLETE_MATH */