YoushouldhavereceivedcopiesoftheGNUGeneralPublicLicenseandthe GNULesserGeneralPublicLicensealongwiththeGNUMPLibrary.Ifnot,
see https://www.gnu.org/licenses/. */
#include"config.h"
#if HAVE_FLOAT_H #include <float.h> /* for DBL_MANT_DIG and FLT_RADIX */ #endif
/* To force use of the generic C code for testing, put
"#define _GMP_IEEE_FLOATS 0" at this point. */
/* In alpha gcc prior to 3.4, signed DI comparisons involving constants are rearrangedfrom"x<n"to"x+(-n)<0",whichisofcoursehopelessly wrongifthatadditionoverflows.
Forreference,notethatHPPA8000,8200,8500and8600trapFCNV,UDW,DBL tothekernelforvalues>=2^63.Thismakesitslow,andworsethekernel Linux(whatversions?)apparentlyusesuntestedcodeinitstraphandling routines,andgetsthesignwrong.Wedon'tusesuchalimb-to-double
cast, neither in the IEEE or generic code. */
#undef FORMAT_RECOGNIZED
double
mpn_get_d (mp_srcptr up, mp_size_t size, mp_size_t sign, long exp)
{ int lshift, nbits;
mp_limb_t x, mhi, mlo;
/* Adjust exp to a radix point just above {up,size}, guarding against overflow.Afterthisexpcanofcoursebereducedtoanywherewithin
the {up,size} region without underflow. */ if (UNLIKELY ((unsignedlong) (GMP_NUMB_BITS * size)
> ((unsignedlong) LONG_MAX - exp)))
{ #if _GMP_IEEE_FLOATS goto ieee_infinity; #endif
{ /* Non-IEEE or strange limb size, generically convert
GMP_DBL_MANT_BITS bits. */
mp_limb_t l; int m;
mp_size_t i; double d, weight; unsignedlong uexp;
/* First generate an fp number disregarding exp, instead keeping things withinthenumbbasefactorfrom1,whichshouldpreventoverflowand
underflow even for the most exponent limited fp formats. */
i = size - 1;
l = up[i];
count_leading_zeros (m, l);
m = m + GMP_DBL_MANT_BITS - GMP_LIMB_BITS; if (m < 0)
l &= GMP_NUMB_MAX << -m;
d = l; for (weight = 1/MP_BASE_AS_DOUBLE; m > 0 && --i >= 0;)
{
l = up[i];
m -= GMP_NUMB_BITS; if (m < 0)
l &= GMP_NUMB_MAX << -m;
d += l * weight;
weight /= MP_BASE_AS_DOUBLE; if (weight == 0) break;
}
/* Now apply exp. */
exp -= GMP_NUMB_BITS; if (exp > 0)
{
weight = 2.0;
uexp = exp;
} else
{
weight = 0.5;
uexp = NEG_CAST (unsignedlong, exp);
} #if1 /* Square-and-multiply exponentiation. */ if (uexp & 1)
d *= weight; while (uexp >>= 1)
{
weight *= weight; if (uexp & 1)
d *= weight;
} #else /* Plain exponentiation. */ while (uexp > 0)
{
d *= weight;
uexp--;
} #endif
return sign >= 0 ? d : -d;
} #endif
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-06-10)
¤
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.