Does the abs() function have a purpose?


I don’t quite understand the purpose of the abs() function. The name of the number is how far it is from zero so by knowing the identity of a number, you know how far it is from zero. Even if the identity of a number is stored as a variable, for example x, one could simply print x to identify the variable.
Is there a higher purpose for this function that I’m missing?


Well, if you have an unknown number (negative or positive) and you want to know how far the number is from zero, abs is very useful. Otherwise you first have to determine if number is negative or positive, now we have a function doing this for us

abs(-42) is 42, that is important to understand


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