Hello, i finish the task but i don't understand how abs works: abs(a<0) return -a, so "minus a" become a positive number!? How? Let say if(-2<0) return -2; =》 become 2 ???
On the other hand if(a<0) return ((-a)*(-a)); =》a
I don' t understand the abs()!
Resolved
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
Lisa
20 September 2021, 06:25
And I think abs are hot... push, push... another push up, yeeeessss, ahhhh 😜🤪
0
SANTOSH PENUGURTHI
19 September 2021, 01:48useful
If the argument is not negative(positive), the argument is returned. If the argument is negative, the negation of the argument is returned.
+2
Lucy
18 September 2021, 14:21
hi, abs works like this:
a = -2
if -2<0 (true) return -(-2)
"a" has its own minus so now you have two ;)
and -(-2) is 2.
if 2<0 (false) go to else: 2>0 (true) so return 2
abs is always positive
+2
Angel Stefan
21 September 2021, 17:02
So it return MINUS(and the number, in our case -2). So - and -2 = 2. Briliant!. Big tk you!
0