Click to See Complete Forum and Search --> : [RESOLVED] display upto 2 places after decimal


raj_2006
08-01-2006, 10:32 AM
Hi ,

I am facing a piculiar problem.Its a mathematical issue.

this is the code

$nt=round($sum-($sum*$dis_amount)/100);

Now say $sum=62 and $disamount=10% so if i do the calculation then it should be

round(62-(62*10)/100)==55.80

Now the output is only 55.8 . But i want to display it as 55.80 means upto 2 places after the decimal point.

Is there any way to display it as like this in PHP..
Please give me an idea.

Thanks for your suggestion in advance.....Luv......Raj

Doc Thirst
08-01-2006, 11:01 AM
Yep, try this out

$grandtotal = number_format($grandtotal, 2, '.', '');

raj_2006
08-01-2006, 11:32 AM
hi

thanks for your suggestion.ya it is working.....:)

but i slight modify it like this

$nt=number_format($nt,2);

Thanks again for your co-operation..........luv........Raj