zlite
June 21, 2008, 4:32am
1
The reference docs say that abs():
"Returns
x: if x is greater than or equal to 0.
-x: if x is less than 0. "
That's not the definition of absolute value as I understand it. I'm pretty sure it should be:
"Returns
x: if x is greater than or equal to 0.
x: if x is less than 0."
system
June 21, 2008, 5:40am
2
If x is -1 then -x is -(-1) which is 1.
--Phil.
bens
June 21, 2008, 6:59am
3
"Returns
x: if x is greater than or equal to 0.
x: if x is less than 0."
This reduces to:
returns x
which would be fairly useless.
zlite
June 21, 2008, 1:49pm
4
My apologies, you're right--they mean the -(-1) = 1 formulation. It's just somewhat obscure and ambiguous phrasing for a very straightforward concept. But I suppose that's computer science for you
bens
June 22, 2008, 8:57am
5
It's basically the standard mathematical way to express what absolute value means. The other way is |x| = sqrt(x^2).