How to compare floats in a Job?

if x == y is not reliable enough due to floating point differences

Mathf.Approximately(x,y) is not available inside Job

How would you compare two float values to 3 decimal places for example?

What about if y is smaller than x?
No Math(Abs) in Job

there is math.abs in the mathematics package

2 Likes

No, this makes no sense. Your condition would always be true. if x is 5 and y is 4 your first condition would be true even though the values are not the same or close to each other. Same when the values are the other way round. In that case the second condition would be true. You would need an && instead of an ||.

Like HellGate94 said inside jobs you should use the math class instead of the Mathf class.

2 Likes

Doh! Didn’t see that, just tried Mathf and got errors. Thanks all!