Hello. How would I take the absolute value of x + y? I want all of the value to be positive.
Example: (-4)+(-4)= -8 but I want that value to be positive.
Any tips or ideas would be greatly appreciated.
Take the absolute value of x plus absolute value of y?
2 Likes
No. You would add them first then you would take the absolute value.
1 Like
Then just take the absolute value?
Are you trying to figure out a command? Just use the abs function. You may have to include a library.
4 Likes
Easiest way to do this is std::abs(x+y);
. Make sure you add #include <cmath>
to the top of your file.
3 Likes
If you use python.
math.fabs(x + y)
1 Like