Re: Round

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/29/07, Zoltán Németh <znemeth@xxxxxxxxxxxxxx> wrote:
> > Think this through before you respond...
> >
> > Try this
> >
> > <?php
> > var_dump( round(-0.26) );
> > var_dump( abs( round(-0.26) ) );
> > var_dump( round(-1.26) );
> > var_dump( abs( round(-1.26) ) );
> > ?>
> >
> > does this give you the desired results?
> >
> > What if I expected -1 for the last answer?

    It didn't take much thinking this time.... if you were expecting
-1 for the last answer, you'd be wrong.  ;-P

    The very nature of abs() is to return an absolute number, which is
never a negative.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list....
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux