Java examples for Language Basics:float
Get to know the Floating-point weirdness
import java.text.NumberFormat; public class Main { public static void main(String[] args) { float x = 0.1f; NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMinimumFractionDigits(10);/*from ww w . ja v a2s. c om*/ System.out.println(x); System.out.println(nf.format(x)); } }