+ 1
What is the primary use abs( ) numeric function?
I don't see the purpose of abs ( ) numeric function because you can just look at value like 30 and you know it's 30 values away from 0.
6 Answers
+ 6
In some cases you may get negative and positive values to process, and you have to treat these numbers only by number but without negative sign. in this case you use abs(-33) gives 33, which is the absolute value.
+ 3
In the case of variables, you don't know up front whether it's value will be positive or negative at a given time.
+ 2
abs(x)
is shorter and more readable than:
(-x if x < 0 else x)
+ 2
ā¤ā¢ā šš¢š¢ššØ šš”šš²šš„ āā¢ā¤ why you use
abs(4+3j)
In this example j is invalid syntax cause of j isn't in quotes(''), maybe.
If it is valid then can you teach me how it is valid?
Please :)