Re: Round

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

 



2007. 08. 29, szerda keltezéssel 09.29-kor Jim Lucas ezt írta:
> Daniel Brown wrote:
> > On 8/29/07, Richard Heyes <richardh@xxxxxxxxxxx> wrote:
> >> Koen van den Boogaart wrote:
> >>> No, I want it to go to float(0), so minus the minus. "-0" doesn't exist in
> >>> math, as far as I know. Probably a precision thing.
> >> Ok, then try abs() first then.
> >>
> >> --
> >> Richard Heyes
> >> +44 (0)844 801 1072
> >> http://www.websupportsolutions.co.uk
> >>
> >> Knowledge Base and HelpDesk software
> >> that can cut the cost of online support
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> > 
> >     Richard (Heyes) is right.
> > 
> >     <?php echo var_dump(abs(round(-0.26)))."\n"; ?>
> > 
> >     Tested on 5.0.4 and 5.2.3.
> > 
> 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?

why would you expect -1 for the last one?
abs(-1) should return 1 AFAIK

that's what the above code produces too.

greets
Zoltán Németh

> 
> 
> -- 
> Jim Lucas
> 
>     "Some men are born to greatness, some achieve greatness,
>         and some have greatness thrust upon them."
> 
> Twelfth Night, Act II, Scene V
>      by William Shakespeare
> 

-- 
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