I have code that examines if a variable elapsedTime (double) is a multiple of 0.4. i.e. 0.4, .0.8, 1.2, 1.6 etc code checks like so:
let roundedInterval = Double(round(timeInterval*10)/10) //(this is 0.4)
let roundedActualElapsedTime = Double(round(actualElapsedTime*10)/10)
if roundedActualElapsedTime%roundedInterval == 0 {
print(“is a multiple of 0.4”)
}
However from my results output 0.4, 0.8, 1.6, 3.2 are being reported as multiples, so it is missing values. Any ideas what I might be doing wrong here?
NOTE: roundedTimeInterval remains constant at 0.4 and roundedActualElapsedTime increments in 0.1s i.e. 0.1, 0.2, 0.3, 0.4... etc