Reply to Re: number_format() question EASY

Your name:

Reply:


Posted by Jerry Stuckle on 02/22/07 19:36

Johannes Vogel wrote:
> Hi
>
> Anonymous wrote:
>> Jerry Stuckle wrote:
>>> $num = int($num);
>> I would advise against type casting. It can produce strage results under
>> some circumstances.
>> He would be better of using $num = floor($num), that's what the function
>> is here for.
>> ceil() always rounds up, floor() always rounds down, round() rounds
>> according to mathematical rules (down on .0 to .4, up on .5 to .9
>
> What's about minus values?
> We don't know what the OP would like to get.
>
> floor(-2.8) => -3
> (int)-2.8 => -2
>
> HTH, Johannes

int(-2.8) is -2, as you indicated. And the operator indicated he wanted
to truncate the value, so floor() would in this case provide an
incorrect value.

Now if he said he wanted the next lower integer, your solution would be
correct.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[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

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