exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / log10l.c
blob20e113a8d341116b162c67dff0c27411bd3450b7
1 /* Base 10 logarithmic function.
2 Copyright (C) 2012-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation, either version 3 of the
7 License, or (at your option) any later version.
9 This file 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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser 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 0 /* was: 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