Java Utililty Methods Float Array Create

List of utility methods to do Float Array Create

Description

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

Method

float[]toFloats(byte[] bytes)
to Floats
int size = toInt(bytes, 0);
float[] result = new float[size];
int offset = SIZEOF_INT;
for (int i = 0; i < size; i++) {
    result[i] = toFloat(bytes, offset);
    offset += SIZEOF_INT;
return result;
...
float[]toFloats(byte[] value, int offset, int num)
to Floats
float[] values = new float[num];
int idx = 0;
for (int i = offset; i < offset + (num * 4); i += 4) {
    values[idx++] = getFloat(value, i);
return values;
float[]toFloats(double[] d)
to Floats
float[] f = new float[d.length];
for (int i = 0; i < f.length; i++)
    f[i] = (float) d[i];
return f;
float[]toFloats(final double[] array)
Converts a double array to a float array.
final float[] ret = new float[array.length];
for (int i = 0; i < ret.length; i++) {
    ret[i] = (float) array[i];
return ret;
float[]toFloats(Float[] values)
to Floats
return toFloats(values, DEFAULT_FLOAT);
float[]toFloats(Object[] extraArgs)
to Floats
float[] ret = new float[extraArgs.length];
for (int i = 0; i < extraArgs.length; i++) {
    ret[i] = Float.valueOf(extraArgs[i].toString());
return ret;
float[]toFloats(String floatArray)
converts float values from string separated by " " (space) to an Array of floats
String[] s = floatArray.split(" ");
float[] f = new float[s.length];
for (int i = 0; i < f.length; i++) {
    f[i] = Float.parseFloat(s[i]);
return f;
floattoFloatValue(Object number)
Returns the number object as a float
if (number instanceof Float) {
    return ((Float) number).floatValue();
if (number instanceof Long) {
    return ((Long) number).floatValue();
if (number instanceof Integer) {
    return ((Integer) number).floatValue();
...
floattoFloatWithoutOverflow(double value)
Like Math#toIntExact(long) but for float range.
if (value < Float.MIN_VALUE || value > Float.MAX_VALUE) {
    throw new ArithmeticException("float overflow");
return (float) value;