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

floattoFloat(short half)
Converts a single precision (32 bit) floating point value into half precision (16 bit).
switch ((int) half) {
case 0x0000:
    return 0f;
case 0x8000:
    return -0f;
case 0x7c00:
    return Float.POSITIVE_INFINITY;
case 0xfc00:
...
float[]toFloat(short[] arr)
Converts an array of short values to an array of float values.
int n = arr.length;
float[] converted = new float[n];
for (int i = 0; i < n; i++) {
    converted[i] = arr[i];
return converted;
float[]toFloat(short[] src)
Convert an array of short 's into an array of float '.
int number = src.length;
float[] dst = new float[number];
for (int j = 0; j < number; ++j) {
    dst[j] = (float) src[j];
return dst;
floattoFloat(String parameter)
to Float
return Float.parseFloat(parameter);
floattoFloat(String property, float f)
tries to parse the given String into a float value if this fails the default value is returned
try {
    return Float.parseFloat(property);
} catch (NumberFormatException ex) {
    return f;
FloattoFloat(String s)
to Float
try {
    return Float.parseFloat(s);
} catch (NumberFormatException e) {
    return new Float(0);
doubletoFloat(String s)
Converts a string into a float
return Float.parseFloat(s);
floattoFloat(String s)
to Float
return toFloat(s, -1);
floattoFloat(String str)

Convert a String to a float, returning 0.0f if the conversion fails.

If the string str is null, 0.0f is returned.

 NumberUtils.toFloat(null)   = 0.0f NumberUtils.toFloat("")     = 0.0f NumberUtils.toFloat("1.5")  = 1.5f 
return toFloat(str, 0.0f);
floattoFloat(String str)
to Float
if (isNumeric(str))
    return Float.valueOf(str);
return 0;