一、前言
关于javolution源码包javolution.lang.MathLib数学库处理类,对常用数字类型进行随机数random、整型转double转换toDoublePow10、平方根sqrt、四舍五入Math.round、正弦余弦函数sin/ cos、绝对值计算abs等处理。
二、源码说明
package javolution.lang;@b@@b@import java.util.Random;@b@@b@public final class MathLib@b@{@b@ private static final Random RANDOM = new Random();@b@ private static final byte[] BIT_LENGTH = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 };@b@ private static final long MASK_63 = 9223372036854775807L;@b@ private static final long MASK_32 = 4294967295L;@b@ private static final int[] POW5_INT = { 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125 };@b@ private static final double LOG2_DIV_LOG10 = 0.301029995663981D;@b@ public static final double E = 2.718281828459045D;@b@ public static final double PI = 3.141592653589793D;@b@ public static final double HALF_PI = 1.570796326794897D;@b@ public static final double TWO_PI = 6.283185307179586D;@b@ public static final double FOUR_PI = 12.566370614359172D;@b@ public static final double PI_SQUARE = 9.869604401089358D;@b@ public static final double LOG2 = 0.6931471805599453D;@b@ public static final double LOG10 = 2.302585092994046D;@b@ public static final double SQRT2 = 1.414213562373095D;@b@ public static final double NaN = (0.0D / 0.0D);@b@ public static final double Infinity = (1.0D / 0.0D);@b@ private static double INV_LOG10 = 0.4342944819032518D;@b@ private static final double NORMALIZATION_FACTOR = 4.656612873077393E-010D;@b@ static final double[] atanhi = { 0.4636476090008061D, 0.7853981633974483D, 0.9827937232473291D, 1.570796326794897D };@b@ static final double[] atanlo = { 2.269877745296169E-017D, 3.061616997868383E-017D, 1.3903311031231E-017D, 6.123233995736766E-017D };@b@ static final double[] aT = { 0.3333333333333293D, -0.1999999999987648D, 0.1428571427250347D, -0.1111111040546236D, 0.09090887133436507D, -0.076918762050448D, 0.06661073137387531D, -0.05833570133790574D, 0.04976877994615932D, -0.03653157274421692D, 0.01628582011536578D };@b@ static final double one = 1.0D;@b@ static final double huge = 1.E+300D;@b@ static final double ln2_hi = 0.6931471803691238D;@b@ static final double ln2_lo = 1.908214929270588E-010D;@b@ static final double two54 = 18014398509481984.0D;@b@ static final double Lg1 = 0.6666666666666735D;@b@ static final double Lg2 = 0.3999999999940942D;@b@ static final double Lg3 = 0.2857142874366239D;@b@ static final double Lg4 = 0.2222219843214978D;@b@ static final double Lg5 = 0.181835721616181D;@b@ static final double Lg6 = 0.1531383769920937D;@b@ static final double Lg7 = 0.1479819860511659D;@b@ static final double zero = 0.0D;@b@ static final double[] halF = { 0.5D, -0.5D };@b@ static final double twom1000 = 9.332636185032189E-302D;@b@ static final double o_threshold = 709.78271289338397D;@b@ static final double u_threshold = -745.13321910194111D;@b@ static final double[] ln2HI = { 0.6931471803691238D, -0.6931471803691238D };@b@ static final double[] ln2LO = { 1.908214929270588E-010D, -1.908214929270588E-010D };@b@ static final double invln2 = 1.442695040888963D;@b@ static final double P1 = 0.166666666666666D;@b@ static final double P2 = -0.002777777777701559D;@b@ static final double P3 = 6.613756321437934E-005D;@b@ static final double P4 = -1.653390220546525E-006D;@b@ static final double P5 = 4.138136797057239E-008D;@b@@b@ public static int random(int min, int max)@b@ {@b@ int next = RANDOM.nextInt();@b@ if ((next >= min) && (next <= max))@b@ return next;@b@ next -= -2147483648;@b@ if ((next >= min) && (next <= max)) {@b@ return next;@b@ }@b@@b@ int interval = 1 + max - min;@b@ if (interval <= 0)@b@ throw new Error("Interval [" + min + ".." + max + "] error");@b@ return (abs(next % interval) + min);@b@ }@b@@b@ public static long random(long min, long max)@b@ {@b@ long next = RANDOM.nextLong();@b@ if ((next >= min) && (next <= max))@b@ return next;@b@ next += -9223372036854775808L;@b@ if ((next >= min) && (next <= max)) {@b@ return next;@b@ }@b@@b@ long interval = 1L + max - min;@b@ if (interval <= 0L)@b@ throw new Error("Interval error");@b@ return (abs(next % interval) + min);@b@ }@b@@b@ public static float random(float min, float max)@b@ {@b@ return (float)random(min, max);@b@ }@b@@b@ public static double random(double min, double max)@b@ {@b@ double next = RANDOM.nextDouble();@b@ return (min + next * max - next * min);@b@ }@b@@b@ public static int bitLength(int i)@b@ {@b@ if (i < 0)@b@ i = -++i;@b@ return ((i < 16777216) ? BIT_LENGTH[(i >>> 16)] + 16 : (i < 65536) ? BIT_LENGTH[(i >>> 8)] + 8 : (i < 256) ? BIT_LENGTH[i] : BIT_LENGTH[(i >>> 24)] + 24);@b@ }@b@@b@ public static int bitLength(long l)@b@ {@b@ int i = (int)(l >> 32);@b@ if (i > 0) {@b@ return ((i < 16777216) ? BIT_LENGTH[(i >>> 16)] + 48 : (i < 65536) ? BIT_LENGTH[(i >>> 8)] + 40 : (i < 256) ? BIT_LENGTH[i] + 32 : BIT_LENGTH[(i >>> 24)] + 56);@b@ }@b@@b@ if (i < 0)@b@ return bitLength(-++l);@b@ i = (int)l;@b@ return ((i < 16777216) ? BIT_LENGTH[(i >>> 16)] + 16 : (i < 65536) ? BIT_LENGTH[(i >>> 8)] + 8 : (i < 256) ? BIT_LENGTH[i] : (i < 0) ? 32 : BIT_LENGTH[(i >>> 24)] + 24);@b@ }@b@@b@ public static int bitCount(long longValue)@b@ {@b@ longValue -= (longValue >>> 1 & 0x55555555);@b@ longValue = (longValue & 0x33333333) + (longValue >>> 2 & 0x33333333);@b@ longValue = longValue + (longValue >>> 4) & 0xF0F0F0F;@b@ longValue += (longValue >>> 8);@b@ longValue += (longValue >>> 16);@b@ longValue += (longValue >>> 32);@b@ return ((int)longValue & 0x7F);@b@ }@b@@b@ public static int numberOfLeadingZeros(long longValue)@b@ {@b@ if (longValue == 0L)@b@ return 64;@b@ int n = 1;@b@ int x = (int)(longValue >>> 32);@b@ if (x == 0) {@b@ n += 32;@b@ x = (int)longValue;@b@ }@b@ if (x >>> 16 == 0) {@b@ n += 16;@b@ x <<= 16;@b@ }@b@ if (x >>> 24 == 0) {@b@ n += 8;@b@ x <<= 8;@b@ }@b@ if (x >>> 28 == 0) {@b@ n += 4;@b@ x <<= 4;@b@ }@b@ if (x >>> 30 == 0) {@b@ n += 2;@b@ x <<= 2;@b@ }@b@ n -= (x >>> 31);@b@ return n;@b@ }@b@@b@ public static int numberOfTrailingZeros(long longValue)@b@ {@b@ int x;@b@ if (longValue == 0L)@b@ return 64;@b@@b@ int n = 63;@b@ int y = (int)longValue;@b@ if (y != 0) {@b@ n -= 32;@b@ x = y;@b@ } else {@b@ x = (int)(longValue >>> 32); }@b@ y = x << 16;@b@ if (y != 0) {@b@ n -= 16;@b@ x = y;@b@ }@b@ y = x << 8;@b@ if (y != 0) {@b@ n -= 8;@b@ x = y;@b@ }@b@ y = x << 4;@b@ if (y != 0) {@b@ n -= 4;@b@ x = y;@b@ }@b@ y = x << 2;@b@ if (y != 0) {@b@ n -= 2;@b@ x = y;@b@ }@b@ return (n - (x << 1 >>> 31));@b@ }@b@@b@ public static int digitLength(int i)@b@ {@b@ if (i >= 0) {@b@ return ((i >= 10) ? 2 : (i >= 100) ? 3 : (i >= 1000) ? 4 : (i >= 10000) ? 5 : (i >= 100000) ? 6 : (i >= 1000000) ? 7 : (i >= 10000000) ? 8 : (i >= 100000000) ? 9 : (i >= 1000000000) ? 10 : 1);@b@ }@b@@b@ if (i == -2147483648)@b@ return 10;@b@ return digitLength(-i);@b@ }@b@@b@ public static int digitLength(long l)@b@ {@b@ if (l >= 0L) {@b@ return ((l >= 10000000000L) ? 11 : (l >= 100000000000L) ? 12 : (l >= 1000000000000L) ? 13 : (l >= 10000000000000L) ? 14 : (l >= 100000000000000L) ? 15 : (l >= 1000000000000000L) ? 16 : (l >= 10000000000000000L) ? 17 : (l >= 100000000000000000L) ? 18 : (l >= 1000000000000000000L) ? 19 : (l <= 2147483647L) ? digitLength((int)l) : 10);@b@ }@b@@b@ if (l == -9223372036854775808L)@b@ return 19;@b@ return digitLength(-l);@b@ }@b@@b@ public static double toDoublePow2(long m, int n)@b@ {@b@ if (m == 0L)@b@ return 0.0D;@b@ if (m == -9223372036854775808L)@b@ return toDoublePow2(-4611686018427387904L, n + 1);@b@ if (m < 0L)@b@ return (-toDoublePow2(-m, n));@b@ int bitLength = bitLength(m);@b@ int shift = bitLength - 53;@b@ long exp = 1075L + n + shift;@b@ if (exp >= 2047L)@b@ return (1.0D / 0.0D);@b@ if (exp <= 0L) {@b@ if (exp <= -54L)@b@ return 0.0D;@b@ return (toDoublePow2(m, n + 54) / 18014398509481984.0D);@b@ }@b@@b@ long bits = (shift > 0) ? (m >> shift) + (m >> shift - 1 & 1L) : m << -shift;@b@@b@ if ((bits >> 52 != 1L) && (++exp >= 2047L))@b@ return (1.0D / 0.0D);@b@ bits &= 4503599627370495L;@b@ bits |= exp << 52;@b@ return Double.longBitsToDouble(bits);@b@ }@b@@b@ public static double toDoublePow10(long m, int n)@b@ {@b@ if (m == 0L)@b@ return 0.0D;@b@ if (m == -9223372036854775808L)@b@ return toDoublePow10(-922337203685477580L, n + 1);@b@ if (m < 0L)@b@ return (-toDoublePow10(-m, n));@b@ if (n >= 0) {@b@ if (n > 308)@b@ return (1.0D / 0.0D);@b@@b@ long x0 = 0L;@b@ long x1 = 0L;@b@ long x2 = m & 0xFFFFFFFF;@b@ long x3 = m >>> 32;@b@ int pow2 = 0;@b@ while (n != 0) {@b@ int i = (n >= POW5_INT.length) ? POW5_INT.length - 1 : n;@b@ int coef = POW5_INT[i];@b@@b@ if ((int)x0 != 0)@b@ x0 *= coef;@b@ if ((int)x1 != 0)@b@ x1 *= coef;@b@ x2 *= coef;@b@ x3 *= coef;@b@@b@ x1 += (x0 >>> 32);@b@ x0 &= 4294967295L;@b@@b@ x2 += (x1 >>> 32);@b@ x1 &= 4294967295L;@b@@b@ x3 += (x2 >>> 32);@b@ x2 &= 4294967295L;@b@@b@ pow2 += i;@b@ n -= i;@b@@b@ long carry = x3 >>> 32;@b@ if (carry != 0L) {@b@ x0 = x1;@b@ x1 = x2;@b@ x2 = x3 & 0xFFFFFFFF;@b@ x3 = carry;@b@ pow2 += 32;@b@ }@b@@b@ }@b@@b@ int shift = 31 - bitLength(x3);@b@ pow2 -= shift;@b@ long mantissa = (shift < 0) ? x3 << 31 | x2 >>> 1 : (x3 << 32 | x2) << shift | x1 >>> 32 - shift;@b@@b@ return toDoublePow2(mantissa, pow2);@b@ }@b@@b@ if (n < -344) {@b@ return 0.0D;@b@ }@b@@b@ long x1 = m;@b@ long x0 = 0L;@b@ int pow2 = 0;@b@ while (true)@b@ {@b@ int shift = 63 - bitLength(x1);@b@ x1 <<= shift;@b@ x1 |= x0 >>> 63 - shift;@b@ x0 = x0 << shift & 0xFFFFFFFF;@b@ pow2 -= shift;@b@@b@ if (n == 0) {@b@ break;@b@ }@b@@b@ int i = (-n >= POW5_INT.length) ? POW5_INT.length - 1 : -n;@b@ int divisor = POW5_INT[i];@b@@b@ long wh = x1 >>> 32;@b@ long qh = wh / divisor;@b@ long r = wh - qh * divisor;@b@ long wl = r << 32 | x1 & 0xFFFFFFFF;@b@ long ql = wl / divisor;@b@ r = wl - ql * divisor;@b@ x1 = qh << 32 | ql;@b@@b@ wh = r << 31 | x0 >>> 32;@b@ qh = wh / divisor;@b@ r = wh - qh * divisor;@b@ wl = r << 32 | x0 & 0xFFFFFFFF;@b@ ql = wl / divisor;@b@ x0 = qh << 32 | ql;@b@@b@ n += i;@b@ pow2 -= i;@b@ }@b@ return toDoublePow2(x1, pow2);@b@ }@b@@b@ public static long toLongPow2(double d, int n)@b@ {@b@ long bits = Double.doubleToLongBits(d);@b@ boolean isNegative = bits >> 63 != 0L;@b@ int exp = (int)(bits >> 52) & 0x7FF;@b@ long m = bits & 0xFFFFFFFF;@b@ if (exp == 2047)@b@ throw new ArithmeticException("Cannot convert to long (Infinity or NaN)");@b@@b@ if (exp == 0) {@b@ if (m == 0L)@b@ return 0L;@b@ return toLongPow2(d * 18014398509481984.0D, n - 54);@b@ }@b@ m |= 4503599627370496L;@b@ long shift = exp - 1023L - 52L + n;@b@ if (shift <= -64L)@b@ return 0L;@b@ if (shift >= 11L)@b@ throw new ArithmeticException("Cannot convert to long (overflow)");@b@@b@ m = (shift >= 0L) ? m << (int)shift : (m >> (int)(-shift)) + (m >> (int)(-(shift + 1L)) & 1L);@b@ return ((isNegative) ? -m : m);@b@ }@b@@b@ public static long toLongPow10(double d, int n)@b@ {@b@ long bits = Double.doubleToLongBits(d);@b@ boolean isNegative = bits >> 63 != 0L;@b@ int exp = (int)(bits >> 52) & 0x7FF;@b@ long m = bits & 0xFFFFFFFF;@b@ if (exp == 2047)@b@ throw new ArithmeticException("Cannot convert to long (Infinity or NaN)");@b@@b@ if (exp == 0) {@b@ if (m == 0L)@b@ return 0L;@b@ return toLongPow10(d * 10000000000000000.0D, n - 16);@b@ }@b@ m |= 4503599627370496L;@b@ int pow2 = exp - 1023 - 52;@b@@b@ if (n >= 0)@b@ {@b@ long x0 = 0L;@b@ long x1 = 0L;@b@ long x2 = m & 0xFFFFFFFF;@b@ long x3 = m >>> 32;@b@ while (n != 0) {@b@ int i = (n >= POW5_INT.length) ? POW5_INT.length - 1 : n;@b@ int coef = POW5_INT[i];@b@@b@ if ((int)x0 != 0)@b@ x0 *= coef;@b@ if ((int)x1 != 0)@b@ x1 *= coef;@b@ x2 *= coef;@b@ x3 *= coef;@b@@b@ x1 += (x0 >>> 32);@b@ x0 &= 4294967295L;@b@@b@ x2 += (x1 >>> 32);@b@ x1 &= 4294967295L;@b@@b@ x3 += (x2 >>> 32);@b@ x2 &= 4294967295L;@b@@b@ pow2 += i;@b@ n -= i;@b@@b@ long carry = x3 >>> 32;@b@ if (carry != 0L) {@b@ x0 = x1;@b@ x1 = x2;@b@ x2 = x3 & 0xFFFFFFFF;@b@ x3 = carry;@b@ pow2 += 32;@b@ }@b@@b@ }@b@@b@ int shift = 31 - bitLength(x3);@b@ pow2 -= shift;@b@ m = (shift < 0) ? x3 << 31 | x2 >>> 1 : (x3 << 32 | x2) << shift | x1 >>> 32 - shift;@b@ }@b@ else@b@ {@b@ long x1 = m;@b@ long x0 = 0L;@b@ while (true)@b@ {@b@ int shift = 63 - bitLength(x1);@b@ x1 <<= shift;@b@ x1 |= x0 >>> 63 - shift;@b@ x0 = x0 << shift & 0xFFFFFFFF;@b@ pow2 -= shift;@b@@b@ if (n == 0) {@b@ break;@b@ }@b@@b@ int i = (-n >= POW5_INT.length) ? POW5_INT.length - 1 : -n;@b@ int divisor = POW5_INT[i];@b@@b@ long wh = x1 >>> 32;@b@ long qh = wh / divisor;@b@ long r = wh - qh * divisor;@b@ long wl = r << 32 | x1 & 0xFFFFFFFF;@b@ long ql = wl / divisor;@b@ r = wl - ql * divisor;@b@ x1 = qh << 32 | ql;@b@@b@ wh = r << 31 | x0 >>> 32;@b@ qh = wh / divisor;@b@ r = wh - qh * divisor;@b@ wl = r << 32 | x0 & 0xFFFFFFFF;@b@ ql = wl / divisor;@b@ x0 = qh << 32 | ql;@b@@b@ n += i;@b@ pow2 -= i;@b@ }@b@ m = x1;@b@ }@b@ if (pow2 > 0)@b@ throw new ArithmeticException("Overflow");@b@ if (pow2 < -63)@b@ return 0L;@b@ m = (m >> -pow2) + (m >> -(pow2 + 1) & 1L);@b@ return ((isNegative) ? -m : m);@b@ }@b@@b@ public static int floorLog2(double d)@b@ {@b@ if (d <= 0.0D)@b@ throw new ArithmeticException("Negative number or zero");@b@ long bits = Double.doubleToLongBits(d);@b@ int exp = (int)(bits >> 52) & 0x7FF;@b@ if (exp == 2047)@b@ throw new ArithmeticException("Infinity or NaN");@b@ if (exp == 0)@b@ return (floorLog2(d * 18014398509481984.0D) - 54);@b@ return (exp - 1023);@b@ }@b@@b@ public static int floorLog10(double d)@b@ {@b@ int guess = (int)(0.301029995663981D * floorLog2(d));@b@ double pow10 = toDoublePow10(1L, guess);@b@ if ((pow10 <= d) && (pow10 * 10.0D > d))@b@ return guess;@b@ if (pow10 > d)@b@ return (guess - 1);@b@ return (guess + 1);@b@ }@b@@b@ public static double toRadians(double degrees)@b@ {@b@ return (degrees * 0.0174532925199433D);@b@ }@b@@b@ public static double toDegrees(double radians)@b@ {@b@ return (radians * 57.295779513082323D);@b@ }@b@@b@ public static double sqrt(double x)@b@ {@b@ return Math.sqrt(x);@b@ }@b@@b@ public static double rem(double x, double y)@b@ {@b@ double tmp = x / y;@b@ if (abs(tmp) <= 9.223372036854776E+018D)@b@ return (x - round(tmp) * y);@b@@b@ return (0.0D / 0.0D);@b@ }@b@@b@ public static double ceil(double x)@b@ {@b@ return Math.ceil(x);@b@ }@b@@b@ public static double floor(double x)@b@ {@b@ return Math.floor(x);@b@ }@b@@b@ public static double sin(double radians)@b@ {@b@ return Math.sin(radians);@b@ }@b@@b@ public static double cos(double radians)@b@ {@b@ return Math.cos(radians);@b@ }@b@@b@ public static double tan(double radians)@b@ {@b@ return Math.tan(radians);@b@ }@b@@b@ public static double asin(double x)@b@ {@b@ if ((x < -1.0D) || (x > 1.0D))@b@ return (0.0D / 0.0D);@b@ if (x == -1.0D)@b@ return -1.570796326794897D;@b@ if (x == 1.0D)@b@ return 1.570796326794897D;@b@ return atan(x / sqrt(1.0D - x * x));@b@ }@b@@b@ public static double acos(double x)@b@ {@b@ return (1.570796326794897D - asin(x));@b@ }@b@@b@ public static double atan(double x)@b@ {@b@ return _atan(x);@b@ }@b@@b@ public static double atan2(double y, double x)@b@ {@b@ double epsilon = 1.E-128D;@b@ if (abs(x) > 1.E-128D) {@b@ double temp = atan(abs(y) / abs(x));@b@ if (x < 0.0D)@b@ temp = 3.141592653589793D - temp;@b@ if (y < 0.0D)@b@ temp = 6.283185307179586D - temp;@b@ return temp; }@b@ if (y > 1.E-128D)@b@ return 1.570796326794897D;@b@ if (y < -1.E-128D)@b@ return 4.71238898038469D;@b@@b@ return 0.0D;@b@ }@b@@b@ public static double sinh(double x)@b@ {@b@ return ((exp(x) - exp(-x)) * 0.5D);@b@ }@b@@b@ public static double cosh(double x)@b@ {@b@ return ((exp(x) + exp(-x)) * 0.5D);@b@ }@b@@b@ public static double tanh(double x)@b@ {@b@ return ((exp(2.0D * x) - 1.0D) / (exp(2.0D * x) + 1.0D));@b@ }@b@@b@ public static double exp(double x)@b@ {@b@ return _ieee754_exp(x);@b@ }@b@@b@ public static double log(double x)@b@ {@b@ return _ieee754_log(x);@b@ }@b@@b@ public static double log10(double x)@b@ {@b@ return (log(x) * INV_LOG10);@b@ }@b@@b@ public static double pow(double x, double y)@b@ {@b@ return Math.pow(x, y);@b@ }@b@@b@ public static int round(float f)@b@ {@b@ return (int)floor(f + 0.5F);@b@ }@b@@b@ public static long round(double d)@b@ {@b@ return ()floor(d + 0.5D);@b@ }@b@@b@ public static double random()@b@ {@b@ return (random(0, 2147483647) * 4.656612873077393E-010D);@b@ }@b@@b@ public static int abs(int i)@b@ {@b@ return ((i < 0) ? -i : i);@b@ }@b@@b@ public static long abs(long l)@b@ {@b@ return ((l < 0L) ? -l : l);@b@ }@b@@b@ public static float abs(float f)@b@ {@b@ return ((f < 0.0F) ? -f : f);@b@ }@b@@b@ public static double abs(double d)@b@ {@b@ return ((d < 0.0D) ? -d : d);@b@ }@b@@b@ public static int max(int x, int y)@b@ {@b@ return ((x >= y) ? x : y);@b@ }@b@@b@ public static long max(long x, long y)@b@ {@b@ return ((x >= y) ? x : y);@b@ }@b@@b@ public static float max(float x, float y)@b@ {@b@ return ((x >= y) ? x : y);@b@ }@b@@b@ public static double max(double x, double y)@b@ {@b@ return ((x >= y) ? x : y);@b@ }@b@@b@ public static int min(int x, int y)@b@ {@b@ return ((x < y) ? x : y);@b@ }@b@@b@ public static long min(long x, long y)@b@ {@b@ return ((x < y) ? x : y);@b@ }@b@@b@ public static float min(float x, float y)@b@ {@b@ return ((x < y) ? x : y);@b@ }@b@@b@ public static double min(double x, double y)@b@ {@b@ return ((x < y) ? x : y);@b@ }@b@@b@ static double _atan(double x)@b@ {@b@ int id;@b@ long xBits = Double.doubleToLongBits(x);@b@ int __HIx = (int)(xBits >> 32);@b@ int __LOx = (int)xBits;@b@@b@ int hx = __HIx;@b@ int ix = hx & 0x7FFFFFFF;@b@ if (ix >= 1141899264) {@b@ if ((ix > 2146435072) || ((ix == 2146435072) && (__LOx != 0)))@b@ {@b@ return (x + x); }@b@ if (hx > 0)@b@ return (atanhi[3] + atanlo[3]);@b@@b@ return (-atanhi[3] - atanlo[3]);@b@ }@b@ if (ix < 1071382528) {@b@ if ((ix < 1042284544) && @b@ (1.E+300D + x > 1.0D))@b@ return x;@b@ id = -1;@b@ } else {@b@ x = abs(x);@b@ if (ix < 1072889856) {@b@ if (ix < 1072037888) {@b@ id = 0;@b@ x = (2.0D * x - 1.0D) / (2.0D + x);@b@ } else {@b@ id = 1;@b@ x = (x - 1.0D) / (x + 1.0D);@b@ }@b@ } else if (ix < 1073971200) {@b@ id = 2;@b@ x = (x - 1.5D) / (1.0D + 1.5D * x);@b@ } else {@b@ id = 3;@b@ x = -1.0D / x;@b@ }@b@ }@b@@b@ double z = x * x;@b@ double w = z * z;@b@@b@ double s1 = z * (aT[0] + w * (aT[2] + w * (aT[4] + w * (aT[6] + w * (aT[8] + w * aT[10])))));@b@ double s2 = w * (aT[1] + w * (aT[3] + w * (aT[5] + w * (aT[7] + w * aT[9]))));@b@ if (id < 0)@b@ return (x - x * (s1 + s2));@b@@b@ z = atanhi[id] - x * (s1 + s2) - atanlo[id] - x;@b@ return ((hx < 0) ? -z : z);@b@ }@b@@b@ static double _ieee754_log(double x)@b@ {@b@ long xBits = Double.doubleToLongBits(x);@b@ int hx = (int)(xBits >> 32);@b@ int lx = (int)xBits;@b@@b@ int k = 0;@b@ if (hx < 1048576) {@b@ if ((hx & 0x7FFFFFFF | lx) == 0)@b@ return (-1.0D / 0.0D);@b@ if (hx < 0)@b@ return ((x - x) / 0.0D);@b@ k -= 54;@b@ x *= 18014398509481984.0D;@b@ xBits = Double.doubleToLongBits(x);@b@ hx = (int)(xBits >> 32);@b@ }@b@ if (hx >= 2146435072)@b@ return (x + x);@b@ k += (hx >> 20) - 1023;@b@ hx &= 1048575;@b@ int i = hx + 614244 & 0x100000;@b@ xBits = Double.doubleToLongBits(x);@b@ int HIx = hx | i ^ 0x3FF00000;@b@ xBits = (HIx & 0xFFFFFFFF) << 32 | xBits & 0xFFFFFFFF;@b@ x = Double.longBitsToDouble(xBits);@b@ k += (i >> 20);@b@ double f = x - 1.0D;@b@ if ((0xFFFFF & 2 + hx) < 3) {@b@ if (f == 0.0D) {@b@ if (k == 0)@b@ return 0.0D;@b@@b@ dk = k;@b@ return (dk * 0.6931471803691238D + dk * 1.908214929270588E-010D);@b@ }@b@ R = f * f * (0.5D - 0.3333333333333333D * f);@b@ if (k == 0)@b@ return (f - R);@b@@b@ dk = k;@b@ return (dk * 0.6931471803691238D - R - dk * 1.908214929270588E-010D - f);@b@ }@b@@b@ double s = f / (2.0D + f);@b@ double dk = k;@b@ double z = s * s;@b@ i = hx - 398458;@b@ double w = z * z;@b@ int j = 440401 - hx;@b@ double t1 = w * (0.3999999999940942D + w * (0.2222219843214978D + w * 0.1531383769920937D));@b@ double t2 = z * (0.6666666666666735D + w * (0.2857142874366239D + w * (0.181835721616181D + w * 0.1479819860511659D)));@b@ i |= j;@b@ double R = t2 + t1;@b@ if (i > 0) {@b@ double hfsq = 0.5D * f * f;@b@ if (k == 0)@b@ return (f - hfsq - s * (hfsq + R));@b@@b@ return (dk * 0.6931471803691238D - hfsq - s * (hfsq + R) + dk * 1.908214929270588E-010D - f); }@b@ if (k == 0)@b@ return (f - s * (f - R));@b@@b@ return (dk * 0.6931471803691238D - s * (f - R) - dk * 1.908214929270588E-010D - f);@b@ }@b@@b@ static double _ieee754_exp(double x)@b@ {@b@ double hi = 0.0D; double lo = 0.0D;@b@ int k = 0;@b@@b@ long xBits = Double.doubleToLongBits(x);@b@ int __HIx = (int)(xBits >> 32);@b@ int __LOx = (int)xBits;@b@@b@ int hx = __HIx;@b@ int xsb = hx >> 31 & 0x1;@b@ hx &= 2147483647;@b@@b@ if (hx >= 1082535490) {@b@ if (hx >= 2146435072) {@b@ if ((hx & 0xFFFFF | __LOx) != 0)@b@ return (x + x);@b@@b@ return ((xsb == 0) ? x : 0.0D); }@b@ if (x > 709.78271289338397D)@b@ return (1.0D / 0.0D);@b@ if (x < -745.13321910194111D)@b@ return 0.0D;@b@@b@ }@b@@b@ if (hx > 1071001154) {@b@ if (hx < 1072734898) {@b@ hi = x - ln2HI[xsb];@b@ lo = ln2LO[xsb];@b@ k = 1 - xsb - xsb;@b@ } else {@b@ k = (int)(1.442695040888963D * x + halF[xsb]);@b@ t = k;@b@ hi = x - t * ln2HI[0];@b@ lo = t * ln2LO[0];@b@ }@b@ x = hi - lo; } else {@b@ if (hx < 1043333120) {@b@ if (1.E+300D + x <= 1.0D) break label229;@b@ return (1.0D + x);@b@ }@b@ k = 0;@b@ }@b@@b@ label229: double t = x * x;@b@ double c = x - t * (0.166666666666666D + t * (-0.002777777777701559D + t * (6.613756321437934E-005D + t * (-1.653390220546525E-006D + t * 4.138136797057239E-008D))));@b@ if (k == 0)@b@ return (1.0D - x * c / (c - 2.0D) - x);@b@@b@ double y = 1.0D - lo - x * c / (2.0D - c) - hi;@b@ long yBits = Double.doubleToLongBits(y);@b@ int __HIy = (int)(yBits >> 32);@b@ if (k >= -1021) {@b@ __HIy += (k << 20);@b@ yBits = (__HIy & 0xFFFFFFFF) << 32 | yBits & 0xFFFFFFFF;@b@ y = Double.longBitsToDouble(yBits);@b@ return y;@b@ }@b@ __HIy += (k + 1000 << 20);@b@ yBits = (__HIy & 0xFFFFFFFF) << 32 | yBits & 0xFFFFFFFF;@b@ y = Double.longBitsToDouble(yBits);@b@ return (y * 9.332636185032189E-302D);@b@ }@b@}