Java Float Number Convert to convertFloatValue(String data)

Here you can find the source of convertFloatValue(String data)

Description

Conversion to Float from String.

License

MIT License

Parameter

Parameter Description
data String data

Return

Float value

Declaration

public static float convertFloatValue(String data) 

Method Source Code

//package com.java2s;
/*/*from  w ww.  java2 s  .  c om*/
 * Copyright (c) 2014 eSOL Co.,Ltd. and Nagoya University
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */

public class Main {
    /**
     * Conversion to Float from String.
     * -1.0f is returned if can not convert.
     * @param data String data
     * @return Float value
     */
    public static float convertFloatValue(String data) {
        float ret = -1.0f;
        if (data != null) {
            try {
                ret = Float.valueOf(data);
            } catch (NumberFormatException e) {
                ret = -1.0f;
            }
        }

        return ret;
    }
}

Related

  1. convertFloatFromStream(byte[] stream, int intStart, int decStart, int intNumbers, int decNumbers)
  2. convertFloatMatrixToDoubles(float[][] input, int dimRows, int dimColoumns)
  3. convertFloatsToFixed(float[] values)
  4. convertFloatToHex(float floatValue)
  5. convertFloatToString(float value)
  6. convertFloatVecToDoubles(float[] input)