]> sourceware.org Git - glibc.git/blobdiff - math/atest-exp2.c
* elf/dl-error.c (_dl_signal_error): When testing for executable
[glibc.git] / math / atest-exp2.c
index 1f5d7ccd8615c462b1b8890ab735e7f208749181..33d942fc61e82933a1a442f4dad8a265c514a293 100644 (file)
@@ -1,25 +1,25 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Geoffrey Keating <Geoff.Keating@anu.edu.au>, 1997.
 
    The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
    The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
 #include <stdio.h>
 #include <math.h>
-#include <stdlib/gmp.h>
+#include <gmp.h>
 #include <string.h>
 #include <limits.h>
 #include <assert.h>
@@ -45,7 +45,7 @@ static const char exp_m1[102] = "0" /* point */
 
 static const char hexdig[] = "0123456789abcdef";
 
-void
+static void
 print_mpn_fp (const mp_limb_t *x, unsigned int dp, unsigned int base)
 {
    unsigned int i;
@@ -66,14 +66,14 @@ print_mpn_fp (const mp_limb_t *x, unsigned int dp, unsigned int base)
      }
 }
 
-void
+static void
 read_mpn_hex(mp_limb_t *x, const char *str)
 {
   int i;
 
   memset (x, 0, sizeof (mp1));
   for (i = -1; i < 100 && i < FRAC / 4; ++i)
-    x[(FRAC - i * 4 - 4) / mpbpl] |= (strchr (hexdig, str[i + 1]) - hexdig
+    x[(FRAC - i * 4 - 4) / mpbpl] |= ((strchr (hexdig, str[i + 1]) - hexdig)
                                      << (FRAC - i * 4 - 4) % mpbpl);
 }
 
@@ -96,7 +96,7 @@ get_log2(void)
 }
 
 /* Compute e^x.  */
-void
+static void
 exp_mpn (mp1 ex, mp1 x)
 {
    unsigned int n;
@@ -107,9 +107,9 @@ exp_mpn (mp1 ex, mp1 x)
 
    memset (xp, 0, sizeof (mp1));
    memset (ex, 0, sizeof (mp1));
-   xp[FRAC / mpbpl] = 1 << FRAC % mpbpl;
+   xp[FRAC / mpbpl] = (mp_limb_t)1 << FRAC % mpbpl;
    memset (tol, 0, sizeof (mp1));
-   tol[(FRAC - TOL) / mpbpl] = 1 << (FRAC - TOL) % mpbpl;
+   tol[(FRAC - TOL) / mpbpl] = (mp_limb_t)1 << (FRAC - TOL) % mpbpl;
 
    n = 0;
 
@@ -130,7 +130,7 @@ exp_mpn (mp1 ex, mp1 x)
 }
 
 /* Calculate 2^x.  */
-void
+static void
 exp2_mpn (mp1 ex, mp1 x)
 {
   mp2 tmp;
@@ -147,11 +147,11 @@ mpn_bitsize(const mp_limb_t *SRC_PTR, mp_size_t SIZE)
   for (i = SIZE - 1; i > 0; --i)
     if (SRC_PTR[i] != 0)
       break;
-  for (j = mpbpl - 1; j > 0; --j)
-    if ((SRC_PTR[i] & 1 << j) != 0)
+  for (j = mpbpl - 1; j >= 0; --j)
+    if ((SRC_PTR[i] & (mp_limb_t)1 << j) != 0)
       break;
 
-  return i * 32 + j;
+  return i * mpbpl + j;
 }
 
 int
@@ -170,7 +170,7 @@ main (void)
 
   memset (maxerror, 0, sizeof (mp1));
   memset (xt, 0, sizeof (mp1));
-  xt[(FRAC - N2) / mpbpl] = 1 << (FRAC - N2) % mpbpl;
+  xt[(FRAC - N2) / mpbpl] = (mp_limb_t)1 << (FRAC - N2) % mpbpl;
 
   for (i = 0; i < (1 << N2); ++i)
     {
@@ -192,7 +192,7 @@ main (void)
 
       e2s = mpn_bitsize (e2, SZ);
       e3s = mpn_bitsize (e3, SZ);
-      if (e3s > 1 && e2s - e3s < 54)
+      if (e3s >= 0 && e2s - e3s < 54)
        {
 #if PRINT_ERRORS
          printf ("%06x ", i * (0x100000 / (1 << N2)));
@@ -219,7 +219,7 @@ main (void)
 
   /* Check exp_mpn against precomputed value of exp(1).  */
   memset (x, 0, sizeof (mp1));
-  x[FRAC / mpbpl] = 1 << FRAC % mpbpl;
+  x[FRAC / mpbpl] = (mp_limb_t)1 << FRAC % mpbpl;
   exp_mpn (ex, x);
   read_mpn_hex (e2, exp1);
   if (mpn_cmp (ex, e2, SZ) >= 0)
This page took 0.034819 seconds and 5 git commands to generate.