Page 1 of 1

How to find the magnitude of a variable without sign[SOLVED]

Posted: Sat Oct 08, 2005 6:54 am
by raghavan20
Suppose if I have -15 or 15, I should get only 15 the magnitude only.
Is there an in-built function available in PHP?

or

Is there a function to identify the sign of an integer (positive or negative)?

Posted: Sat Oct 08, 2005 7:01 am
by n00b Saibot

Posted: Sat Oct 08, 2005 7:05 am
by raghavan20
I found another way

Code: Select all

$pad_zeros_length = -34234;
		echo "pad_zeros_length:". $pad_zeros_length;
		$pad_zeros_length = $pad_zeros_length < 0? -($pad_zeros_length):$pad_zeros_length;
		echo "pad_zeros_length:". $pad_zeros_length;