Reply to Currency rounding

Your name:

Reply:


Posted by shortbackandsides.no on 05/14/07 16:01

This snippet:
<?php
$price=round(111,2);
$tax=round($price*0.175,2);
$total=round($price*1.175,2);

echo $price <br />";
echo "Tax at 17.5% $tax<br />";
echo "Total $total<br />";
?>
gives the result:

111
Tax at 17.5% 19.42
Total 130.43

Two questions.
Why the rounding difference?
and is there a standard function to force the 111 to display as 111.00
(given that price won't always be a whole number)?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация