Don't rely on excess precision: -4 > -3.00000024 - 1 can evaluate to false
[gnulib.git] / lib / math.in.h
index 5138c95..93eeb93 100644 (file)
@@ -2,10 +2,10 @@
 
    Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc.
 
-   This program is free software; you can redistribute it and/or modify
+   This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,8 +13,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef _GL_MATH_H
 
@@ -39,11 +38,11 @@ extern "C" {
      If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
      If x is zero: mantissa = x, exp = 0.
      If x is infinite or NaN: mantissa = x, exp unspecified.
-   Store exp and return mantissa.  */
+   Store exp in *EXPPTR and return mantissa.  */
 #if @GNULIB_FREXP@
 # if @REPLACE_FREXP@
 #  define frexp rpl_frexp
-extern double frexp (double x, int *exp);
+extern double frexp (double x, int *expptr);
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef frexp
@@ -65,6 +64,7 @@ extern long double acosl (long double x);
      acosl (x))
 #endif
 
+
 #if @GNULIB_MATHL@ || !@HAVE_DECL_ASINL@
 extern long double asinl (long double x);
 #endif
@@ -76,6 +76,7 @@ extern long double asinl (long double x);
      asinl (x))
 #endif
 
+
 #if @GNULIB_MATHL@ || !@HAVE_DECL_ATANL@
 extern long double atanl (long double x);
 #endif
@@ -87,17 +88,34 @@ extern long double atanl (long double x);
      atanl (x))
 #endif
 
-#if @GNULIB_MATHL@ || !@HAVE_DECL_CEILL@
-extern long double ceill (long double x);
+
+#if @GNULIB_CEILF@
+# if !@HAVE_DECL_CEILF@
+#  define ceilf rpl_ceilf
+extern float ceilf (float x);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef ceilf
+# define ceilf(x) \
+    (GL_LINK_WARNING ("ceilf is unportable - " \
+                      "use gnulib module ceilf for portability"), \
+     ceilf (x))
 #endif
-#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
+
+#if @GNULIB_CEILL@
+# if !@HAVE_DECL_CEILL@
+#  define ceill rpl_ceill
+extern long double ceill (long double x);
+# endif
+#elif defined GNULIB_POSIXCHECK
 # undef ceill
 # define ceill(x) \
     (GL_LINK_WARNING ("ceill is unportable - " \
-                      "use gnulib module mathl for portability"), \
+                      "use gnulib module ceill for portability"), \
      ceill (x))
 #endif
 
+
 #if @GNULIB_MATHL@ || !@HAVE_DECL_COSL@
 extern long double cosl (long double x);
 #endif
@@ -109,6 +127,7 @@ extern long double cosl (long double x);
      cosl (x))
 #endif
 
+
 #if @GNULIB_MATHL@ || !@HAVE_DECL_EXPL@
 extern long double expl (long double x);
 #endif
@@ -120,29 +139,46 @@ extern long double expl (long double x);
      expl (x))
 #endif
 
-#if @GNULIB_MATHL@ || !@HAVE_DECL_FLOORL@
-extern long double floorl (long double x);
+
+#if @GNULIB_FLOORF@
+# if !@HAVE_DECL_FLOORF@
+#  define floorf rpl_floorf
+extern float floorf (float x);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef floorf
+# define floorf(x) \
+    (GL_LINK_WARNING ("floorf is unportable - " \
+                      "use gnulib module floorf for portability"), \
+     floorf (x))
 #endif
-#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
+
+#if @GNULIB_FLOORL@
+# if !@HAVE_DECL_FLOORL@
+#  define floorl rpl_floorl
+extern long double floorl (long double x);
+# endif
+#elif defined GNULIB_POSIXCHECK
 # undef floorl
 # define floorl(x) \
     (GL_LINK_WARNING ("floorl is unportable - " \
-                      "use gnulib module mathl for portability"), \
+                      "use gnulib module floorl for portability"), \
      floorl (x))
 #endif
 
+
 /* Write x as
      x = mantissa * 2^exp
    where
      If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
      If x is zero: mantissa = x, exp = 0.
      If x is infinite or NaN: mantissa = x, exp unspecified.
-   Store exp and return mantissa.  */
+   Store exp in *EXPPTR and return mantissa.  */
 #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@
 # define frexpl rpl_frexpl
 #endif
 #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@
-extern long double frexpl (long double x, int *exp);
+extern long double frexpl (long double x, int *expptr);
 #endif
 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
 # undef frexpl
@@ -152,6 +188,7 @@ extern long double frexpl (long double x, int *exp);
      frexpl (x, e))
 #endif
 
+
 /* Return x * 2^exp.  */
 #if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@
 # define ldexpl rpl_ldexpl
@@ -167,6 +204,7 @@ extern long double ldexpl (long double x, int exp);
      ldexpl (x, e))
 #endif
 
+
 #if @GNULIB_MATHL@ || !@HAVE_DECL_LOGL@
 extern long double logl (long double x);
 #endif
@@ -178,6 +216,7 @@ extern long double logl (long double x);
      logl (x))
 #endif
 
+
 #if @GNULIB_MATHL@ || !@HAVE_DECL_SINL@
 extern long double sinl (long double x);
 #endif
@@ -189,6 +228,7 @@ extern long double sinl (long double x);
      sinl (x))
 #endif
 
+
 #if @GNULIB_MATHL@ || !@HAVE_DECL_SQRTL@
 extern long double sqrtl (long double x);
 #endif
@@ -200,6 +240,7 @@ extern long double sqrtl (long double x);
      sqrtl (x))
 #endif
 
+
 #if @GNULIB_MATHL@ || !@HAVE_DECL_TANL@
 extern long double tanl (long double x);
 #endif
@@ -212,6 +253,46 @@ extern long double tanl (long double x);
 #endif
 
 
+#if @GNULIB_TRUNCF@
+# if !@HAVE_DECL_TRUNCF@
+#  define truncf rpl_truncf
+extern float truncf (float x);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef truncf
+# define truncf(x) \
+    (GL_LINK_WARNING ("truncf is unportable - " \
+                      "use gnulib module truncf for portability"), \
+     truncf (x))
+#endif
+
+#if @GNULIB_TRUNC@
+# if !@HAVE_DECL_TRUNC@
+#  define trunc rpl_trunc
+extern double trunc (double x);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef trunc
+# define trunc(x) \
+    (GL_LINK_WARNING ("trunc is unportable - " \
+                      "use gnulib module trunc for portability"), \
+     trunc (x))
+#endif
+
+#if @GNULIB_TRUNCL@
+# if !@HAVE_DECL_TRUNCL@
+#  define truncl rpl_truncl
+extern long double truncl (long double x);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef truncl
+# define truncl(x) \
+    (GL_LINK_WARNING ("truncl is unportable - " \
+                      "use gnulib module truncl for portability"), \
+     truncl (x))
+#endif
+
+
 #if @GNULIB_SIGNBIT@
 # if @REPLACE_SIGNBIT@
 #  undef signbit