bitset: properly use false/true instead of 0/1 for Booleans
[gnulib.git] / lib / log10l.c
blob7cb5ed5af17db6be427fe1e4feacd4198a156ad2
1 /* Base 10 logarithmic function.
2 Copyright (C) 2012-2018 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 #include <config.h>
19 /* Specification. */
20 #include <math.h>
22 #if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
24 long double
25 log10l (long double x)
27 return log10 (x);
30 #elif HAVE_LOG10L
32 # include <float.h>
34 long double
35 log10l (long double x)
36 # undef log10l
38 /* Work around the OSF/1 5.1 bug. */
39 if (x == 0.0L)
40 /* Return -Infinity. */
41 return -1.0L / 0.0L;
43 long double y = log10l (x);
44 # ifdef __sgi
45 /* Normalize the +Infinity value. */
46 if (y > LDBL_MAX)
47 y = 1.0L / 0.0L;
48 # endif
49 return y;
53 #else
55 /* 1 / log(10) */
56 static const long double inv_log10 =
57 0.43429448190325182765112891891660508229439700580366656611445378316586464920887L;
59 long double
60 log10l (long double x)
62 return logl (x) * inv_log10;
65 #endif