Re: Round
| From: | Jim Lucas | Date: | Wed, 29 Aug 2007 16:29:08 +0000 |
| Subject: | Re: Round | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-261464@lists.php.net to get a copy of this message | ||
Daniel Brown wrote:
On 8/29/07, Richard Heyes <richardh@phpguru.org> wrote: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? -- 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 ShakespeareKoen 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.phpRichard (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...