Q:

Format method of Decimalformat returns numeric instead zero

I am using DecimalFormat's format method to format float value with 6 decimal points.  So I am using, 
Float f = new Float("52.2815");
DecimalFormat decfo = new DecimalFormat("#0.000000");
String k = decfo.format(f);

I want to print 52.281500. But it prints 52.281502. How to get 52.281500?

A:

This is because floating points don't have enough bits and hence your output data is soured. You can use a Double.
import java.text.DecimalFormat;

public class Solution {

    public static void main(String[] args) {

        Double f = new Double("52.2815");
        DecimalFormat decfo = new DecimalFormat("#.000000");
        String k = decfo.format(f);
        System.out.println(k);
    }
}

Output: 
52.281500

