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 mean by that,
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:
ternary:
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);
}
It turns
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 (allowing
* 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:
If you want to
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
Nevermind,
I have been using if($number0) { //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
7 matches
Mail list logo