Java Fraction Format format(float number, int bitCount)

Here you can find the source of format(float number, int bitCount)

Description

format

License

Apache License

Declaration

public static String format(float number, int bitCount) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String format(float number, int bitCount) {
        String result = "";
        String strbit = "";
        for (int i = 0; i < bitCount; i++) {
            strbit += "0";
        }//from   w  w  w. j a  v  a  2  s.c o  m
        java.text.DecimalFormat df = new java.text.DecimalFormat("#." + strbit);
        result = df.format(number);

        return result;
    }
}

Related

  1. format(final double value, final int decimalPlaces)
  2. format(final NumberFormat fmt, final double val)
  3. format(float f)
  4. format(Float f)
  5. format(float num)
  6. format(float totalNumberOfFreeBytes)
  7. format(float value)
  8. format(NumberFormat nf, float number, float defaultValue)
  9. format0(Double d)