Java Utililty Methods Double Convert to

List of utility methods to do Double Convert to

Description

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

Method

StringconvertDoubleNumberFromSciNotation(String numberInScientificNotation)
convert Double Number From Sci Notation
int index = -1;
if ((index = numberInScientificNotation.lastIndexOf('E')) != -1) {
    short length = (short) numberInScientificNotation.length();
    String exponential = numberInScientificNotation.substring(index + 1, length);
    String prefix = numberInScientificNotation.substring(0, 1);
    String suffix = numberInScientificNotation.substring(2, index);
    int expo = Integer.parseInt(exponential);
    String number = prefix + suffix;
...
double[]convertDoubles(Double[] doubles)
convert Doubles
double[] ret = new double[doubles.length];
int i = 0;
while (i < doubles.length) {
    ret[i] = doubles[i];
    i++;
return ret;
StringconvertDoubleShareToString(double shares)
convert Double Share To String
return String.format("%.3f", shares);
longconvertDoubleSizeToViPRLong(double size)
convert Double Size To Vi PR Long
double kSize = size / KBYTES;
return Double.valueOf(kSize).longValue();
float[]convertDoublesToFloats(double[] input)
converts a double array into a float array; USE WITH CAUTION as precision might be lost!
if (input == null) {
    return null;
float[] output = new float[input.length];
for (int i = 0; i < input.length; i++) {
    output[i] = (float) input[i];
return output;
...
Double[][]convertdoubleToDouble(double[][] dbleArray)
Converts a double array to a Double array.
Double[][] dblArrayToReturn = new Double[dbleArray.length][2];
if (dbleArray != null) {
    for (int i = 0; i < dbleArray.length; i++) {
        int j = 0;
        dblArrayToReturn[i][j] = dbleArray[i][j];
        dblArrayToReturn[i][j + 1] = dbleArray[i][j + 1];
return dblArrayToReturn;
float[][]convertDoubleToFloat(final double[][] doubleSeries)
convert Double To Float
final float[][] floatSeries = new float[doubleSeries.length][];
for (int serieIndex = 0; serieIndex < doubleSeries.length; serieIndex++) {
    final double[] doubleValues = doubleSeries[serieIndex];
    if (doubleValues != null) {
        final float[] floatSerie = floatSeries[serieIndex] = new float[doubleValues.length];
        for (int floatIndex = 0; floatIndex < floatSerie.length; floatIndex++) {
            floatSeries[serieIndex][floatIndex] = (float) doubleValues[floatIndex];
return floatSeries;
LongconvertDoubleToLong(Double value)
convert Double To Long
return value == null ? 0L : Long.parseLong(value.toString().replace(".0", ""));
doubleconvertDoubleToPercentage(double doub)
convert Double To Percentage
return doub * 100;
shortconvertDoubleToShort(double value)
convert Double To Short
double min = Short.MIN_VALUE;
double max = Short.MAX_VALUE;
short r = (short) ((value * (max - min)) - min);
return r;