I'm having trouble in a condition i want in a if statement. I want to check if a variable(float type), like 0.9, is multiple of 0.1.
I had this code: (t * dt) % 0.1 == 0
I've tried the modulo operator but gave me inaccurate results. For example 0.3 is not a multiple of 0.1. Can you help me?
Decimalwould be a viable approach)a = np.array([0.1, 0.2, 0.3]) ; n = 0.1 ; m = a%n ; out = np.isclose(m, 0) | np.isclose(m, n)