Copyright 2001-2003, 2005, 2013 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite.
The GNU MP Library test suite 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 3 of the License, or (at your option) any later version.
The GNU MP Library test suite 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with
the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */
#include <math.h>
#include"testutils.h"
/* FIXME: Not sure if the tests here are exhaustive. Ought to try to get
each possible exit from mpz_cmp_d (and mpz_cmpabs_d) exercised. */
#define SGN(n) ((n) > 0 ? 1 : (n) < 0 ? -1 : 0)
void
check_one (constchar *name, mpz_srcptr x, double y, int cmp, int cmpabs)
{ int got;
/* With the mpz differing by 1, in a limb position possibly below the double */ void
check_low_z_one (void)
{
mpz_t x; double y; unsignedlong i;
mpz_init (x);
/* FIXME: It'd be better to base this on the float format. */ #ifdefined (__vax) || defined (__vax__) #define LIM 127 /* vax fp numbers have limited range */ #else #define LIM 512 #endif
for (i = 1; i < LIM; i++)
{
mpz_set_ui (x, 1L);
mpz_mul_2exp (x, x, i);
y = mpz_get_d (x);
/* Comparing 1 and 1+2^-n. "y" is volatile to make gcc store and fetch it, which forces it to a 64-bit double, whereas on x86 it would otherwise
remain on the float stack as an 80-bit long double. */ void
check_one_2exp (void)
{ double e;
mpz_t x; volatiledouble y; int i;
mpz_init (x);
e = 1.0; for (i = 0; i < 128; i++)
{
e /= 2.0;
y = 1.0 + e; if (y == 1.0) break;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.