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

29th Aug 2020, 3:45 PM
Hilary
Hilary - avatar
4 ответов
+ 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.
29th Aug 2020, 3:53 PM
Lothar
Lothar - avatar
+ 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.
29th Aug 2020, 11:02 PM
Sonic
Sonic - avatar
+ 2
abs(x) is shorter and more readable than: (-x if x < 0 else x)
29th Aug 2020, 3:56 PM
Seb TheS
Seb TheS - avatar
+ 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 :)
29th Aug 2020, 4:49 PM
Anonymous
Anonymous - avatar