15. abs() | Wrong definition of absolute function?



The description before the instructions says:
"The abs() function always returns a positive value, ..."
-> this would exclude the return of "0" since its not:
"The abs() function always returns a [not/non negative] value..."
or am i wrong ?

Just wondering :wink:


Try it out, instead of setting it to -42 set it to 0.

absolute = abs(0)

print absolute

Prints 0


I mean yes, it works with 0 but isnt the definition still wrong?


Not really. Since 0 is technically not a negative or positive number, it will return 0. For example, if you have 0$ , you have neither an excess(positive) or debt(negative). So you have 0$. Same thing here, it will return 0. :slight_smile:

(There are almost always exceptions. 0 being one of them)


Hmm since i learned that the mathmatical defintion of an absoulte function is that the return is "not negative" since this means x>=0,
where as "positive" means x>0.


The definition of absolute value is the distance from 0. Since 0 is no distance from 0, it will return 0. Since -42 is 42 away from 0 it returns 42.


Isn't this definition just a way to think of the absoulte value/function ?
You can check the definition of the absoulte value/function in wikipedia for example and it says "non-negative".


Wikipedia is not always the best source to go to because it can be edited by anyone, and therefore can be unreliable at times. Check out this Varsity Tutors link :slight_smile:



Well nowdays Wikipedia is more reliable then it used to be. But still i belive the wording in the description is incorrect, because the absolute value function is:
f(x) = |x|, where f(x) ≥ 0 for all values of x
f(x)≥0 <- this means non-negative result.
But positive results mean f(x) >0.
I am not arguing with you personally :slight_smile: but just trying to clear up the "error" in the description.


I agree with you there, Wikipedia has gotten more reliable but you wouldn't use it for a research paper or for school so I try and stay away from it :slight_smile:
So you're saying it should be:
f(x) = |x|, where f(x) ≥= 0 for all values of x (positive)
f(x)≥= 0 <- (negative).


No i mean that
f(x)≥ 0 means non-negative (0 can be a result)
f(x)> 0 means positive (0 cant be a result)
but because the result of an absolute value function can be 0, it has to be "a non-negative result" and not "a positive result" .


Ah, I see what you mean now. Excluding 0, the abs() function always returns a positive number. Right? But since 0 is neither positive nor negative the 'positive result' definition still works since 0 is neither and therefore excluded.


No the "positive result" definition is wrong since it excludes 0 as a result where as "non-negative result" has 0 and all positive results


Non·neg·a·tive: either positive or equal to zero.

Positive numbers are numbers that are greater than zero.

Zero is neither positive nor negative, but is a non-negative number

I see what you mean. Honestly, it doesn't really matter because most automatically assume that 0 is 'not positive' and the opposite of 'not positive' is negative, so absolute value gets 'positive result' slapped on it. If you wanted to be that technical, then yes, you would be correct.



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.