Get difference of two floats

Hi,

How i can get the (positive) difference beetween two floats? The floats (X1, X2) are positive and negative.

So, i have for example 1#
X1= -1500, X2= -800

or for Example 2#
X1= -200 X2=100

or 3#
X1=300 X2=700

How can i calculate the difference between this two floats.
1# = would be 700, for 2# 300 and for 3# 400
I dont found a node for this in blueprints. I found only subtract. But i cannot use just subract because some floats are positive and negative and sometimes they are only positive or only negative.
The calculated difference should be always positive. Maybe write a blueprint function in a library in C++for this to use this in blueprints? How can i do this?

I have tried this but it didnt work well because sometimes X1 is greater than X2 and sometimes X2 is greater than X1.
I need this for this to calculate the scale (size)value of the box: Check if player in Region without Volume - Blueprint - Epic Developer Community Forums

The X1, Y1, Z1 is the left bottom corner in world space coordinates and the X2, Y2, Z2 are right top corner also in world space coordinates.

The X1, Y1, Z1 is the pivot of the box and the location in the World where the box is placed.

The values are all from my 3DS max scene. Since its not possible to convert volume shapes from 3ds max to ue4 i need this way to do this.

FittFräsen’s answer should work:

example 1# X1= -1500, X2= -800:

  • abs(X1 - X2) = abs(-1500 -(-800)) = abs(-1500 + 800) = abs(-700) = 700
  • abs(X2 - X1) = abs(-800 -(-1500)) = abs(-800 + 1500) = abs(700) = 700

or for Example 2# X1= -200 X2=100

  • abs(X1 - X2) = abs(-200 - 100) = abs(-300) = 300
  • abs(X2 - X1) = abs(100 -(-200)) = abs(100 + 200) = abs(300) = 300

or example 3# X1=300 X2=700

  • abs(X1 - X2) = abs(300 - 700) = abs(-400) = 400
  • abs(X2 - X1) = abs(700 - 300) = abs(400) = 400

That should be true in BP or C++.

Hope that helps!

Andy

I haven’t tried it but couldn’t you just take X1 - X2 and take the absolute value of the result? That way you would always get a positive delta X