chanchelkumar Posted November 20, 2008 Share Posted November 20, 2008 Hi all, Am doing some calculations say 5*2.5=12.5 But i want to get the ans as..12.50, But now it is getting like 12.5.. How will i get this? Any one please help me.. Link to comment https://forums.phpfreaks.com/topic/133487-solved-some-calculation-error-in-php/ Share on other sites More sharing options...
waynew Posted November 20, 2008 Share Posted November 20, 2008 12.5 is the same as 12.50? Link to comment https://forums.phpfreaks.com/topic/133487-solved-some-calculation-error-in-php/#findComment-694257 Share on other sites More sharing options...
zenag Posted November 20, 2008 Share Posted November 20, 2008 use nymber_format... $number=111.90; echo number_format($number,2,'.',''); Link to comment https://forums.phpfreaks.com/topic/133487-solved-some-calculation-error-in-php/#findComment-694259 Share on other sites More sharing options...
Gighalen Posted November 20, 2008 Share Posted November 20, 2008 Or you could try using something like: <?php round($value, 2) ?> I think. I'm not sure. Link to comment https://forums.phpfreaks.com/topic/133487-solved-some-calculation-error-in-php/#findComment-694368 Share on other sites More sharing options...
chanchelkumar Posted November 21, 2008 Author Share Posted November 21, 2008 use nymber_format... $number=111.90; echo number_format($number,2,'.',''); Thanks Ganesh... It works... Link to comment https://forums.phpfreaks.com/topic/133487-solved-some-calculation-error-in-php/#findComment-695133 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.