Hi, I am trying to display my floating point values as money in a machine. Now When I display the value 0.60, the zero is omitted from the end and as such is displayed as 0.6. I need to display it as 0.60.

Many thanks in advance.

You'll need to use a formatter like DecimalFormat or String.format().

float value = 0.60f;
DecimalFormat df = new DecimalFormat("0.00");
String formattedValue = df.format(value);

I think this will help you..
// To display the Decimal
float amt=0.60f;

NumberFormat formatter;
formatter=NumberFormat.getIntegerInstance();
formatter.setMinimumFractionDigits(2);

System.out.println(formatter.format(amt));

Many thanks. This thread is closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.