Greetings,
I am trying to understand the purpose of this code
private static double scale(double x, int n)
2363: {
2364: if (Configuration.DEBUG && abs(n) >= 2048)
2365: throw new InternalError("Assertion failure");
2366: if (x == 0 || x == Double.NEGATIVE_INFINITY
2367: || ! (x < Double.POSITIVE_INFINITY) || n == 0)
2368: return x;
2369: long bits = Double.doubleToLongBits(x);
2370: int exp = (int) (bits >> 52) & 0x7ff;
2371: if (exp == 0)
2372: {
2373: x *= TWO_54;
2374: exp = ((int) (Double.doubleToLongBits(x) >> 52) & 0x7ff) - 54;
2375: }
2376: exp += n;
2377: if (exp > 0x7fe)
2378: return Double.POSITIVE_INFINITY * x;
2379: if (exp > 0)
2380: return Double.longBitsToDouble((bits & 0x800fffffffffffffL)
2381: | ((long) exp << 52));
2382: if (exp <= -54)
2383: return 0 * x;
2384: exp += 54;
2385: x = Double.longBitsToDouble((bits & 0x800fffffffffffffL)
2386: | ((long) exp << 52));
2387: return x * (1 / TWO_54);
2388: }
I do not understand what Configuration.DEBUG is doing. Simple example will be helpful.
The above masterpiece comes from the following link: http://developer.classpath.org/doc/java/lang/StrictMath-source.html
I am attempting it to translate it (configuration.debug as well) to c++ and possible use it in other java applications.
Thanks in advance.
Adam