Go Down

Topic: Error in abs() documentation? (Read 525 times) previous topic - next topic

zlite

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."

follower

If x is -1 then -x is -(-1) which is 1.

--Phil.

Quote
"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

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 ;-)

It's basically the standard mathematical way to express what absolute value means.  The other way is |x| = sqrt(x^2).

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy