Vaupell
01-03-2010, 01:09 PM
Doing some calculations that may wary depending on the user, and
content calculated ofcourse..
But ewentually its bound to happen i will hit values below 0
and using integers as whole numbers no decimals
one calc could be as simple as
$result=$contentA-$ContentB
But i feel like i dont have control over it,
it might end up being 100 - 10 and will result in -90
So ive found the php manual and read about abs();
But got worried reading all the comments below
http://php.net/manual/en/function.abs.php
-----------------
What i want, is if the case is that $result ends up as a negative value i just
want to turn it positive. so in the case above the -90 would be 90.
was thinking doing something like this
$result=$contentA-$ContentB
if ($result <= 0)
{
$result=$abs3($result);
}
Is that far fetched ? or is there a better solution ?
content calculated ofcourse..
But ewentually its bound to happen i will hit values below 0
and using integers as whole numbers no decimals
one calc could be as simple as
$result=$contentA-$ContentB
But i feel like i dont have control over it,
it might end up being 100 - 10 and will result in -90
So ive found the php manual and read about abs();
But got worried reading all the comments below
http://php.net/manual/en/function.abs.php
-----------------
What i want, is if the case is that $result ends up as a negative value i just
want to turn it positive. so in the case above the -90 would be 90.
was thinking doing something like this
$result=$contentA-$ContentB
if ($result <= 0)
{
$result=$abs3($result);
}
Is that far fetched ? or is there a better solution ?