annotate lib/log10.c @ 17848:ab58d4870664

version-etc: new year * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date. * all files: Run 'make update-copyright'.
author Paul Eggert <eggert@cs.ucla.edu>
date Thu, 01 Jan 2015 01:38:23 +0000
parents 344018b6e5d7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16736
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Base 10 logarithmic function.
17848
ab58d4870664 version-etc: new year
Paul Eggert <eggert@cs.ucla.edu>
parents: 17587
diff changeset
2 Copyright (C) 2012-2015 Free Software Foundation, Inc.
16736
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 /* Specification. */
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #include <math.h>
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 double
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 log10 (double x)
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #undef log10
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 {
16745
78fe2a20b15c log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16736
diff changeset
26 if (x <= 0.0)
78fe2a20b15c log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16736
diff changeset
27 {
78fe2a20b15c log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16736
diff changeset
28 /* Work around the OSF/1 5.1 bug. */
78fe2a20b15c log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16736
diff changeset
29 if (x == 0.0)
78fe2a20b15c log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16736
diff changeset
30 /* Return -Infinity. */
78fe2a20b15c log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16736
diff changeset
31 return -1.0 / 0.0;
78fe2a20b15c log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16736
diff changeset
32 /* Work around the NetBSD 5.1, Solaris 11 2011-11 bug. */
78fe2a20b15c log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16736
diff changeset
33 else /* x < 0.0 */
78fe2a20b15c log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16736
diff changeset
34 /* Return NaN. */
78fe2a20b15c log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16736
diff changeset
35 return 0.0 / 0.0;
78fe2a20b15c log10-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16736
diff changeset
36 }
16736
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 return log10 (x);
747e0285fa98 log10: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 }