List of utility methods to do Double to
String | doubleToFractionStr(final Double d) Converts a double to a string fraction, i.e. boolean negative = false; Double v = d; if (v < 0) { negative = true; v = -v; int w = (int) ((v - Math.floor(v)) * FACTOR); int gcd = gcd(w, FACTOR); ... |
String | doubleToHashString(double value) double To Hash String StringBuilder sb = new StringBuilder(16); long bits = Double.doubleToLongBits(value); for (int i = 7; i >= 0; i--) { int byteValue = (int) ((bits >>> (8 * i)) & 0xff); int high = ((byteValue >> 4) & 0xf); int low = (byteValue & 0xf); sb.append(HEX_CHARACTERS[high]); sb.append(HEX_CHARACTERS[low]); ... |
String | doubleToHexString(double val) double To Hex String long reversed = Long.reverseBytes(Double.doubleToLongBits(val)); String res = Long.toHexString(reversed); res = "0000000000000000".substring(res.length()) + res; return res; |
String | doubleToI18nString(double d) double To In String return doubleToI18nString(d, false);
|
int | doubleToIndex(final double x) double To Index final long j = Double.doubleToRawLongBits(x); final long k = j >>> (64 - BITS); assert k <= Integer.MAX_VALUE; return (int) k; |
byte[] | doubleToLex(double v) Converts a regular java double to a lexicographical sortable double long l = Double.doubleToLongBits(v); if (Double.isNaN(v)) { } else if (v >= 0) { l ^= c64; } else { l ^= 0xFFFFFFFFFFFFFFFFL; return longBytes(l, new byte[8], 0); ... |
String | doubleToPercent(double value, int precision) Convert a double value to percentage long tempValue = Math.round(value * (Math.pow(10, (precision + 2)))); String percentValue = null; if (precision == 0) percentValue = String.valueOf((double) tempValue); else percentValue = String.valueOf(((double) tempValue) / (Math.pow(10, precision))); percentValue += '%'; return percentValue; ... |
long[] | doubleToRational(double number) double To Rational if ((number == 0.0d) || Double.isNaN(number)) { throw new IllegalArgumentException(number + " cannot be represented as a rational number"); long bits = Double.doubleToLongBits(number); long sign = bits >>> 63; long exponent = ((bits >>> 52) ^ (sign << 11)) - 1023; long fraction = bits << 12; long a = 1L; ... |
byte[] | doubleToRegisters(double d) Converts a double value to a byte[8]. return longToRegisters(Double.doubleToLongBits(d));
|
int | doubleToScale(double val) Converts a double to a 24 bit register value. int temp = (int) (val * (double) 0x400000); if (temp > 0x7fffff) { temp = 0x7fffff; if (temp < -0x800000) { temp = -0x800000; return temp; ... |