Java Utililty Methods Float Number Convert to

List of utility methods to do Float Number Convert to

Description

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

Method

StringconvertFloat(float amount, boolean speech)
Converts a float to speakable fraction representation
int num = (int) amount;
String start = Integer.toString(num);
int remainder = (int) ((amount - num) * 1000);
if (start.equals("0")) {
    start = "";
} else if (remainder > 0) {
    if (speech) {
        start += " and ";
...
floatconvertFloat(String str, float defaults)
convert Float
if (str == null) {
    return defaults;
try {
    return Float.parseFloat(str);
} catch (Exception e) {
    return defaults;
Float[]convertFloatArray(float[] arr)
convert Float Array
Float[] ret = new Float[arr.length];
for (int i = 0; i < arr.length; i++) {
    ret[i] = arr[i];
return ret;
StringconvertFloatArrayToString(float[] value, String separator)
convert Float Array To String
if (value.length == 0) {
    return "";
StringBuilder sb = new StringBuilder();
for (float v : value) {
    sb.append(v);
    sb.append(separator);
sb.setLength(sb.length() - separator.length());
return sb.toString();
shortconvertFloatBitsToHFloat(final int floatBits)
convert Float Bits To H Float
final int s = (floatBits >> 16) & 0x00008000;
int e = ((floatBits >> 23) & 0x000000ff) - (127 - 15);
int m = floatBits & 0x007fffff;
if (e <= 0) {
    if (e < -10) {
        return (short) s;
    m |= 0x00800000;
...
double[]convertFloatDouble(float[] in)
Convert a 1-D float array to double []
double[] out = new double[in.length];
for (int i = 0; i < out.length; i++) {
    out[i] = (double) in[i];
return out;
floatconvertFloatFromBytes(byte[] byteArray)
convert Float From Bytes
return convertFloatFromBytes(byteArray, 0);
floatconvertFloatFromStream(byte[] stream, int intStart, int decStart, int intNumbers, int decNumbers)
convert Float From Stream
float dec;
float num;
float d;
float thous = 0f, units = 0f, tens = 0f, hundreds = 0f, tenths = 0f, hundredths = 0f, thousands = 0f,
        tenthousands = 0f, hunthousands = 0f, millis = 0f;
if (intNumbers > 3) {
    thous = getThousands(stream, intStart);
    intStart++;
...
double[][]convertFloatMatrixToDoubles(float[][] input, int dimRows, int dimColoumns)
convert Float Matrix To Doubles
if (input == null) {
    return null; 
double[][] output = new double[dimRows][dimColoumns];
for (int i = 0; i < dimRows; i++) {
    for (int j = 0; j < dimColoumns; j++) {
        output[i][j] = input[i][j];
return output;
int[]convertFloatsToFixed(float[] values)
convert Floats To Fixed
int[] fixed = new int[values.length];
for (int i = 0; i < values.length; i++) {
    fixed[i] = XDoubleToFixed(values[i]);
return fixed;