## Math operator to return the same value regardless if it is minus or plus.

Find quick help here to get you started with Hollywood
Bugala
Posts: 995
Joined: Sun Feb 14, 2010 7:11 pm

### Math operator to return the same value regardless if it is minus or plus.

I checked through math library, and at least didnt see anything that seemed like it would do following.

I have this situation where there is A - B = C.

However, end result is not known wether it goes to plus or minus side. However, regardless of which side it goes, it will still increase the distance the same amount.

As example, if it is -2 the distance to travel to -2 is 2. If it is +2, then distance to travel to +2 is 2.

What I was looking for was to do it simply like this:

C = A - B

distance = distance + C

however, now I have to do some extra hoops to first find out if it is plus or minus side, and then do the conversion to get it right, instead of just having:

distance = distance + mathfunction(C)

Is there really not one to do that, or I just missed it? If there isnt, then a request for one for future.

bitRocky
Posts: 116
Joined: Fri Nov 14, 2014 6:01 pm

### Re: Math operator to return the same value regardless if it is minus or plus.

I think what you are looking for is Abs()!

Code: Select all

``````distance = distance + Abs(C)
``````

Bugala
Posts: 995
Joined: Sun Feb 14, 2010 7:11 pm

### Re: Math operator to return the same value regardless if it is minus or plus.

ah, thanks. Didnt realise from its description that is what it meant.

@Andreas, add an example of "-2" returns "2", to make it more understandable for the one who dont fully comprehend the math language, I read the description but didnt understand it meant that.