Java Float Number Format formatFloat(float f)

Here you can find the source of formatFloat(float f)

Description

format Float

License

Open Source License

Declaration

public static String formatFloat(float f) 

Method Source Code

//package com.java2s;
/*//from   w  ww.j  ava2s. com
 * Copyright (c) 2014 tabletoptool.com team.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     rptools.com team - initial implementation
 *     tabletoptool.com team - further development
 */

public class Main {
    public static String formatFloat(float f) {
        if (f == (int) f)
            return String.format("%d", (int) f);
        else
            return String.format("%s", f);
    }
}

Related

  1. formatFloat(double num)
  2. formatFloat(double number, int precision)
  3. formatFloat(double value, int decimals)
  4. formatFloat(float input, int numDecimals)
  5. formatFloat(float num, int width, int precision)
  6. formatFloat(float val)
  7. formatFloat(String value)