Reply to RE: [PHP] Round to the nearest X

Your name:

Reply:


Posted by Jared Williams on 04/29/05 00:45

> I realize this is a dumb question but I just can't come up
> with an equation that will do this and I don't see an
> internal PHP function (for version 4.3) that will do this...
> Basically I need to come up with an equation/algorithm that
> will round any number up/down to the nearest X.
> I tried using
>
> y +/- (y mod x)
>
> but after I started putting in some test numbers, it didn't
> always work. For example,
>
> 37678 + ( 37678 % 500 )
>
> did not round up to the nearest 500.
>

37678 + 500 - (37678 % 500)



Jared

[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

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