You are here: Re: PHP round() bug? « PHP Programming Language « IT news, forums, messages
Re: PHP round() bug?

Posted by Anonymous on 05/25/05 05:58

db_guy wrote:
>
> <?
> $a=1.5345493;
>
> $b=round($a,2);
>
> echo "b: ".$b;
> ?>
>
> This code should return "b: 1.54", but instead returns "b: 1.53". Can
> anyone else confirm this?
>
> Also, does anyone have a way around this issue?

Since 1.534... is smaller than 1.535, round($a,2) will correctly round
it down to 1.53. I wouldn't know what should be wrong with that.

Check the rounding functions. There are also functions that always round
up or down, namely ceil() and floor(). Maybe you were looking for ceil()
instead of round()?

 

Navigation:

[Reply to this 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

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