Java Utililty Methods Double Number From

List of utility methods to do Double Number From

Description

The list of methods to do Double Number From are organized into topic(s).

Method

doubletoDoubleAsUnsigned(long v)
to Double As Unsigned
if (v >= 0)
    return (double) v;
double dbl = v;
dbl += Math.pow(2, 64);
return dbl;
DoubletoDoubleByObject(Object obj)
to Double By Object
try {
    return Double.valueOf(toStringByObject(obj, true));
} catch (Exception e) {
    return 0.0d;
StringtoDoubleDigit(int number)
to Double Digit
if (number >= 0 && number < 10) {
    return "0" + ((Integer) number).toString();
return ((Integer) number).toString();
double[][]toDoubleMatrix(Number[][] matrix)
Turns the Number matrix into one consisting of primitive doubles.
double[][] result;
int i;
int n;
result = new double[matrix.length][];
for (i = 0; i < matrix.length; i++) {
    result[i] = new double[matrix[i].length];
    for (n = 0; n < matrix[i].length; n++)
        result[i][n] = matrix[i][n].doubleValue();
...
DoubletoDoubleObject(Object obj)
Converts an Object to a Double.
if (obj == null) {
    return null;
if (obj instanceof Double) {
    return (Double) obj;
if (obj instanceof Number) {
    return new Double(((Number) obj).doubleValue());
...
doubletoDoublePow10(long m, int n)
Returns the closest double representation of the specified long number multiplied by a power of ten.
assert m >= 0;
if (m == 0)
    return 0.0;
if (n >= 0) { 
    if (n > 308)
        return Double.POSITIVE_INFINITY;
    long x0 = 0; 
    long x1 = 0; 
...
doubletoDoublePow2(long m, int n)
Returns the closest double representation of the specified long number multiplied by a power of two.
assert m >= 0;
if (m == 0)
    return 0.0;
int bitLength = Long.SIZE - Long.numberOfLeadingZeros(m);
int shift = bitLength - 53;
long exp = 1023L + 52 + n + shift; 
if (exp >= 0x7FF)
    return Double.POSITIVE_INFINITY;
...
doubletoDoublePrecision(long fixedPrecisionOrdinate)
Converts the requested coordinate from fixed to double precision.
double ordinate = (double) fixedPrecisionOrdinate / FIXED_PRECISION_FACTOR;
return ordinate;
double[]toDoublePrimitiveArray(final Double[] wrappedArray)
Returns the primitive double array from wrapper double array
final double[] array = new double[wrappedArray.length];
for (int i = 0; i < wrappedArray.length; i++) {
    array[i] = wrappedArray[i].intValue();
return array;
StringtoDoubleQuotes(String str)
Takes a string, surrounds it with double-quotes and escapes all double-quotes already in the string according to Unix rules.
StringBuilder buf = new StringBuilder();
buf.append('"');
if (str != null) {
    int len = str.length();
    for (int i = 0; i < len; i++) {
        char c = str.charAt(i);
        if (c == '"') {
            buf.append('\\');
...