Here you can find the source of format(float number, int bitCount)
public static String format(float number, int bitCount)
//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; } }