stepify not working on y axis but working on x axis

Attention Topic was automatically imported from the old Question2Answer platform.

I am making a match statement that compares a vector’s x and y values, however, it only works for my x-axis.

``````print(distance_to)
print(vector2_to_string_match(distance_to))
var y_axis = stepify(distance_to.y, 0.1)
var x_axis = stepify(distance_to.x, 0.1)
print(str("y axis = ", y_axis, ", x axis = ", x_axis, "\ny_axis == -0.7 which is ", y_axis == -0.7,
"\nx_axis == -0.8 which is ", x_axis == -0.8))
``````

the results give me

(-0.754222, -0.656619)
y axis = -0.7, x axis = -0.8
y_axis == -0.7 which is False
x_axis == -0.8 which is True

I recreated it in a new godot project and it’s still working like this.

``````var vector = Vector2(-0.751234, -0.6545)
var y_axis = stepify(vector.y, 0.1)
var x_axis = stepify(vector.x, 0.1)

print(x_axis == -0.8) # returns True
print(y_axis == -0.7)# returns False
``````

should the x_axis not be returning .6?

scrubswithnosleeves | 2021-05-08 15:44

na if its 0.5 it rounds up.
so it’s its 0.65 it would round the 5 up to be 0.7.
I believe that’s how it works at least.

halcyon | 2021-05-08 15:47

``````prints(x_axis == -0.8, y_axis, is_equal_approx(y_axis, -0.7))
`is_equal_approx()` fixes the issue