Java Utililty Methods Float Number Create

List of utility methods to do Float Number Create

Description

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

Method

float[]toFloat(double[] in)
to Float
float[] out = new float[in.length];
for (int i = 0; i < in.length; i++) {
    out[i] = (float) in[i];
return out;
float[]toFloat(double[] v)
to Float
final float[] ans = new float[v.length];
for (int k = 0; k < v.length; k++)
    ans[k] = (float) v[k];
return (ans);
floattoFloat(final byte[] ba)
Converts a byte[4] array to a float by placing the bytes after each other and interpreting is according to the IEEE 754 floating-point "single precision" bit layout (the one used by java and several other programming languages).
return Float.intBitsToFloat(toInt(ba));
floattoFloat(final byte[] inputBytes, final int offset)
to Float
return Float.intBitsToFloat(toInt(inputBytes, offset));
FloattoFloat(final Integer value)
to Float
Float converted = null;
if (null != value) {
    converted = value.floatValue();
return converted;
FloattoFloat(final Object o, final String pattern)
to Float
if (o == null) {
    return null;
} else if (o instanceof Float) {
    return (Float) o;
} else if (o instanceof Number) {
    return new Float(((Number) o).floatValue());
} else if (o instanceof String) {
    return toFloat((String) o);
...
FloattoFloat(final Object obj)
to Float
Float f = null;
if (obj != null) {
    if (obj instanceof Double) {
        f = ((Double) obj).floatValue();
    } else if (obj instanceof Float) {
        f = (Float) obj;
return f;
FloattoFloat(final Object valueRep)
to Float
return Float.parseFloat(String.valueOf(valueRep));
FloattoFloat(final String value)
Converts a String to a float plus if the String is NULL, the returned value will be NULL.
if (value == null) {
    return null;
return Float.valueOf(value);
floattoFloat(final String value)
To float.
if (value == null) {
    return 0.0F;
String szTemp = "";
for (int i = 0; i < value.length(); i++)
    if (value.charAt(i) != ',') {
        szTemp = szTemp + value.charAt(i);
try {
    final float f = Float.parseFloat(szTemp);
    return f;
} catch (final NumberFormatException e) {
    final float f1 = 0.0F;
    return f1;