 # How to always get a positive math result even when the true result is a negative number?

One of the projects asks for you to compare actual costs to estimated costs and add an output statement. Three of the four customers are paying less so I am getting a positive number as a value based on the order I have the actual cost and the compared cost in my variable calculation. i.e. actual - estimate = positive number.

So here is my question, is there a way to get the one instance of the customer paying more that gives me a negative number with this a-b= -c , where c is a negative number to be positive? Obviously I could make it positive by performing estimate - actual = positive number and this is what I did but I was taking advantage of a lot of copy and paste and didn’t catch it until I read the output. How would you perform that math and guarantee a positive number?

I’m brand new and I apologize if this seems like a really dumb or useless question. I’m just really curious and all of the reference documentation is overwhelming. Thanks in advance if you read this!

Levi

Hey, there’s no dumb questions.
It sounds like what you’re after is called the ‘absolute value’ ( e.g. putting in -2 or +2 would result in +2)
Not sure what language you’re working in, but hopefully that should help you search.

Feel free to follow up if you’re still having issues.

The key is resolve the difference as ‘less than’ or ‘more than’. We cannot do that if we make it an absolute value.

``````if actual - estimate > 0 then cost overrun is actual - estimate

if actual - estimate < 0 then cost was under budget by actual - estimate``````