# float -2 decimal point

Hi,
I have this in jsp page.

String a_c = "100.00";
String b_c = "100.55";
float d_f = Float.parseFloat(a_c);
float e_f = Float.parseFloat(b_c);

out.print(d_f + "<br>" + e_f);

The output i get is :
100.0
100.55

My question is how to make the output
100.00
100.55
I mean i want the float always have 2 decimal point.
###### Who is Participating?

Commented:
...
java.text.DecimalFormat df = new java.text.DecimalFormat("#0.0");
out.print(df.format(d_f) + "<br>" + df.format(e_f));
0

Commented:
java.text.DecimalFormat df = new java.text.DecimalFormat("#0.00");
0

Commented:
<%
String a_c = "100.00";
String b_c = "100.55";
float d_f = Float.parseFloat(a_c);
float e_f = Float.parseFloat(b_c);

java.text.DecimalFormat decimalFormat = new java.text.DecimalFormat("0.00");

out.print(decimalFormat.format(d_f) + "<br>" + decimalFormat.format(e_f));
%>
0

Commented:
jose_tijo, thanks a lot,but we've alredy seen that!
The points are for Venci75!
0

Commented:
Hey
No probs:) . I was trying to help u a little more

Tijo
0

Senior Developer/ArchitectCommented:
Alternatively, use the java.math.BigDecimal class. It will represent _exactly_ the value it is asked to hold, not _approximately_ like float or double. If scaling or rounding is necessary it can do that too. And conversion to various primitive types is supported.

Best regards,
Jim Cakalic
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.