Well, your question may not be the answer you want, really.  If you just
want to change a number from a negative to a positive(and vice versa), you
can multiply your number by -1.

   I suspect, however, that what you really want is a way to return the
absolute value of your variable.  To do that, I believe you can use the
abs() function.  It should return the absolute value(i.e. positive value) of
any number passed to it, so it is safe to use it on your positive and
negative numbers to the same result.

-----Original Message-----
From: Stuart Clark
To: perllist
Sent: 3/11/02 7:02 PM
Subject: negative to positive

Hi all

How do i change a negative value to a positive?

EG

$number1 = -100;
$number2 = 50;

$result = $number2 - $number1;


The $result variable would equal -50

I want to change the script so it would equal 50

so something like this $result = makethisapositive($number2 - $number1);
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------------------
This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to