how to get sign of a number
Posted: Wed Jul 05, 2006 12:10 pm
there is a number and i want to know weather its a +ve number or a -ve number how can i find this?
thanks
dizyn
thanks
dizyn
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$positive = ($number >= 0);What about 0? 0 isn't positive...feyd wrote:Code: Select all
$positive = ($number >= 0);
I understand what you are saying here... But I don't agree with:feyd wrote:Nor is it negative. So? I'd let itsmani1 choose whether he wants zero to be considered negative or positive or something else.
since it's not open for a discussion... 0 is not positive nor negative.feyd wrote:whether he wants zero to be considered negative or positive or something else.
Again, I agree with you except to this part: "zero, though it is not a negative value, can be associated with positive values as a default non-negative.".Everah wrote:I think the concept Feyd offered is a useful point. Whether the OP wants to check for zero as a value is beside the point. Not to mention that zero, though it is not a negative value, can be associated with positive values as a default non-negative.
But more importantly, Feyd offered a sugestion to get the OP pointed in the proper direction, in my opinion.