Re: [PHP] Re: negative numbers

2004-12-28 Thread Jason Wong
On Tuesday 28 December 2004 01:13, Ford, Mike wrote: > > abs(): > > > > $doo = -20; > > for ($i = 1; $i < 1000; $i++) { > > $dah = abs($doo); > > } > > That's not a valid benchmark, since only on the first pass through the loop > is $doo negative. I'm not sure what you m

Re: [PHP] Re: negative numbers

2004-12-27 Thread Curt Zirzow
* Thus wrote Ford, Mike: > To view the terms under which this email is distributed, please go to > http://disclaimer.leedsmet.ac.uk/email.htm > > > > > -Original Message- > > From: Jason Wong > > Sent: 27/12/04 10:16 > > > > On Monday 27 December 2004 12:40, Richard Lynch wrote: > > >

RE: [PHP] Re: negative numbers

2004-12-27 Thread Ford, Mike
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm > -Original Message- > From: Jason Wong > Sent: 27/12/04 10:16 > > On Monday 27 December 2004 12:40, Richard Lynch wrote: > > > If you want to mimic the behaviour of abs (a

Re: [PHP] Re: negative numbers

2004-12-27 Thread Greg Donald
On Mon, 27 Dec 2004 18:16:21 +0800, Jason Wong <[EMAIL PROTECTED]> wrote: > ternary: > >$doo = -20; >for ($i = 1; $i < 1000; $i++) { >$dah = ($doo < 0) ? - $doo : $doo; >} > > abs(): > >$doo = -20; >for ($i = 1; $i < 1000; $i++) { >$dah = abs($doo); >

Re: [PHP] Re: negative numbers

2004-12-27 Thread Jason Wong
On Monday 27 December 2004 12:40, Richard Lynch wrote: > If you want to mimic the behaviour of abs (allowing for positive numbers) > and performance was an issue, that: > $x = ($x < 0) ? - $x : $x; > > is most likely faster than abs() Having nothing better to do I decided to benchmark this: tern

[PHP] Re: negative numbers

2004-12-26 Thread Richard Lynch
I've managed to delete the original post, so apologies in advance if I got the Subject wrong and/or am missing the threading headers. Plus, this post isn't even strictly necessary, and could be construed as pedantic. Oh well. To change -40 to 40, http://php.net/abs is probably the best answer fr

[PHP] RE: negative numbers

2002-09-25 Thread Mike Dunlop
Nevermind, I have been using if($number<0) { //negative number... but it wasn't working correctly due to a str_replace statement that removing zeros which was screwing it up ok later -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php