Hi Khoo!

If your trying to convert a 'String' value to 'float', then why not just use
the wrapper class.

For example:

String    strNumber = "10.25";
float       floatNumber = 0.0;

floatNumber = Float.parseFloat(strNumber);

'floatNumber' would now contain the float value of 10.25. to which you can
do any arithmetic with.

Hope this helps you out.

Regards

David Gowe
----- Original Message -----
From: Khoo Swee Chin <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 12, 2000 8:55 AM
Subject: Float problem in JSP


> Hi there,
>
> can somebody help me out with the float problem i'm having. I am new with
> JSP.
> i try to convert a string to a float to do a calculation in jsp, but the
> results turn out to be not what i expected, here are my code:
> ....
> <% float SumTotalValue = 0 ;%>
>
> <repeat index = i>
> <%bnViewPOCHolder.getPO_No(i);%>
>
>        <% float TotalValue = new
> Float(bnViewPOCHolder.getNet_Total(i)).floatValue();%>
>                  <% SumTotalValue = SumTotalValue + TotalValue ;%>
> </repeat>
> <%=a.format(SumTotalValue)%>
> ........
>
> Sometimes i get a float number like 522.061 instead of 522.06 and
sometimes
> it's ok.
> What should i do? How can i set the decimal places to 2?
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to