publicstaticdouble compute(double x) { double t = 0.0; double sign;
if (x == 0.0 || !Double.isFinite(x)) return x; // Handles signed zeros properly
sign = (x < 0.0) ? -1.0: 1.0;
x = Math.abs(x); // x <- |x|
// Rough cbrt to 5 bits if (x < 0x1.0p-1022) { // subnormal number
t = 0x1.0p54; // set t= 2**54
t *= x;
t = __HI(t, __HI(t)/3 + B2);
} else { int hx = __HI(x); // high word of x
t = __HI(t, hx/3 + B1);
}
// New cbrt to 23 bits, may be implemented in single precision double r, s, w;
r = t * t/x;
s = C + r*t;
t *= G + F/(s + E + D/s);
// Chopped to 20 bits and make it larger than cbrt(x)
t = __LO(t, 0);
t = __HI(t, __HI(t) + 0x00000001);
// One step newton iteration to 53 bits with error less than 0.667 ulps
s = t * t; // t*t is exact
r = x / s;
w = t + t;
r = (r - t)/(w + r); // r-s is exact
t = t + t*r;
// Restore the original sign bit return sign * t;
}
}
publicstaticdouble compute(double x, double y) { double a = Math.abs(x); double b = Math.abs(y);
if (!Double.isFinite(a) || !Double.isFinite(b)) { if (a == INFINITY || b == INFINITY) return INFINITY; else return a + b; // Propagate NaN significand bits
}
if (b > a) { double tmp = a;
a = b;
b = tmp;
} assert a >= b;
// Doing bitwise conversion after screening for NaN allows // the code to not worry about the possibility of // "negative" NaN values.
// Note: the ha and hb variables are the high-order // 32-bits of a and b stored as integer values. The ha and // hb values are used first for a rough magnitude // comparison of a and b and second for simulating higher // precision by allowing a and b, respectively, to be // decomposed into non-overlapping portions. Both of these // uses could be eliminated. The magnitude comparison // could be eliminated by extracting and comparing the // exponents of a and b or just be performing a // floating-point divide. Splitting a floating-point // number into non-overlapping portions can be // accomplished by judicious use of multiplies and // additions. For details see T. J. Dekker, A Floating-Point // Technique for Extending the Available Precision, // Numerische Mathematik, vol. 18, 1971, pp.224-242 and // subsequent work.
int ha = __HI(a); // high word of a int hb = __HI(b); // high word of b
if ((ha - hb) > 0x3c00000) { return a + b; // x / y > 2**60
}
int k = 0; if (a > 0x1.00000_ffff_ffffp500) { // a > ~2**500 // scale a and b by 2**-600
ha -= 0x25800000;
hb -= 0x25800000;
a = a * TWO_MINUS_600;
b = b * TWO_MINUS_600;
k += 600;
} double t1, t2; if (b < 0x1.0p-500) { // b < 2**-500 if (b < Double.MIN_NORMAL) { // subnormal b or 0 */ if (b == 0.0) return a;
t1 = 0x1.0p1022; // t1 = 2^1022
b *= t1;
a *= t1;
k -= 1022;
} else { // scale a and b by 2^600
ha += 0x25800000; // a *= 2^600
hb += 0x25800000; // b *= 2^600
a = a * TWO_PLUS_600;
b = b * TWO_PLUS_600;
k -= 600;
}
} // medium size a and b double w = a - b; if (w > b) {
t1 = 0;
t1 = __HI(t1, ha);
t2 = a - t1;
w = Math.sqrt(t1*t1 - (b*(-b) - t2 * (a + t1)));
} else { double y1, y2;
a = a + a;
y1 = 0;
y1 = __HI(y1, hb);
y2 = b - y1;
t1 = 0;
t1 = __HI(t1, ha + 0x00100000);
t2 = a - t1;
w = Math.sqrt(t1*y1 - (w*(-w) - (t1*y2 + t2*b)));
} if (k != 0) { return Math.powerOfTwoD(k) * w;
} else return w;
}
}
publicstaticdouble compute(finaldouble x, finaldouble y) { double z; double r, s, t, u, v, w; int i, j, k, n;
// y == zero: x**0 = 1 if (y == 0.0) return1.0;
// +/-NaN return x + y to propagate NaN significands if (Double.isNaN(x) || Double.isNaN(y)) return x + y;
finaldouble y_abs = Math.abs(y); double x_abs = Math.abs(x); // Special values of y if (y == 2.0) { return x * x;
} elseif (y == 0.5) { if (x >= -Double.MAX_VALUE) // Handle x == -infinity later return Math.sqrt(x + 0.0); // Add 0.0 to properly handle x == -0.0
} elseif (y_abs == 1.0) { // y is +/-1 return (y == 1.0) ? x : 1.0 / x;
} elseif (y_abs == INFINITY) { // y is +/-infinity if (x_abs == 1.0) return y - y; // inf**+/-1 is NaN elseif (x_abs > 1.0) // (|x| > 1)**+/-inf = inf, 0 return (y >= 0) ? y : 0.0; else// (|x| < 1)**-/+inf = inf, 0 return (y < 0) ? -y : 0.0;
}
finalint hx = __HI(x); int ix = hx & 0x7fffffff;
/* *Whenx<0,determineifyisanoddinteger: *y_is_int=0...yisnotaninteger *y_is_int=1...yisanoddint *y_is_int=2...yisanevenint
*/ int y_is_int = 0; if (hx < 0) { if (y_abs >= 0x1.0p53) // |y| >= 2^53 = 9.007199254740992E15
y_is_int = 2; // y is an even integer since ulp(2^53) = 2.0 elseif (y_abs >= 1.0) { // |y| >= 1.0 long y_abs_as_long = (long) y_abs; if ( ((double) y_abs_as_long) == y_abs) {
y_is_int = 2 - (int)(y_abs_as_long & 0x1L);
}
}
}
// Special value of x if (x_abs == 0.0 ||
x_abs == INFINITY ||
x_abs == 1.0) {
z = x_abs; // x is +/-0, +/-inf, +/-1 if (y < 0.0)
z = 1.0/z; // z = (1/|x|) if (hx < 0) { if (((ix - 0x3ff00000) | y_is_int) == 0) {
z = (z-z)/(z-z); // (-1)**non-int is NaN
} elseif (y_is_int == 1)
z = -1.0 * z; // (x < 0)**odd = -(|x|**odd)
} return z;
}
n = (hx >> 31) + 1;
// (x < 0)**(non-int) is NaN if ((n | y_is_int) == 0) return (x-x)/(x-x);
s = 1.0; // s (sign of result -ve**odd) = -1 else = 1 if ( (n | (y_is_int - 1)) == 0)
s = -1.0; // (-ve)**(odd int)
publicstaticdouble compute(double x) { double y; double hi = 0.0; double lo = 0.0; double c; double t; int k = 0; int xsb; /*unsigned*/ int hx;
hx = __HI(x); /* high word of x */
xsb = (hx >> 31) & 1; /* sign bit of x */
hx &= 0x7fffffff; /* high word of |x| */
/* filter out non-finite argument */ if (hx >= 0x40862E42) { /* if |x| >= 709.78... */ if (hx >= 0x7ff00000) { if (((hx & 0xfffff) | __LO(x)) != 0) return x + x; /* NaN */ else return (xsb == 0) ? x : 0.0; /* exp(+-inf) = {inf, 0} */
} if (x > o_threshold) return huge * huge; /* overflow */ if (x < u_threshold) // unsigned compare needed here? return twom1000 * twom1000; /* underflow */
}
/* argument reduction */ if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
hi = x - ln2HI[xsb];
lo=ln2LO[xsb];
k = 1 - xsb - xsb;
} else {
k = (int)(invln2 * x + half[xsb]);
t = k;
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
x = hi - lo;
} elseif (hx < 0x3e300000) { /* when |x|<2**-28 */ if (huge + x > one) return one + x; /* trigger inexact */
} else {
k = 0;
}
/* x is now in primary range */
t = x * x;
c = x - t*(P1 + t*(P2 + t*(P3 + t*(P4 + t*P5)))); if (k == 0) return one - ((x*c)/(c - 2.0) - x); else
y = one - ((lo - (x*c)/(2.0 - c)) - hi);
if(k >= -1021) {
y = __HI(y, __HI(y) + (k << 20)); /* add k to y's exponent */ return y;
} else {
y = __HI(y, __HI(y) + ((k + 1000) << 20)); /* add k to y's exponent */ return y * twom1000;
}
}
}
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.19Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-06)
¤
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.