2 Copyright (C) 2012-2017 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/>. */
22 /* Best possible approximation of log(2) as a 'double'. */
23 #define LOG2 0.693147180559945309417232121458176568075
25 /* Best possible approximation of 1/log(2) as a 'double'. */
26 #define LOG2_INVERSE 1.44269504088896340735992468100189213743
29 #define SQRT_HALF 0.707106781186547524400844362104849039284
40 /* Return -Infinity. */
45 #if defined _MSC_VER || (defined __sgi && !defined __GNUC__)
59 Then log2(x) = e + log2(y) = e + log(y)/log(2). */
71 return (double) e
+ log (y
) * LOG2_INVERSE
;