I have a piece of code as:
let gate = 0.0 // 1.4 1.3 1.2
let xGate = NSNumber(value: gate)
let xValue = Double(round(xGate.floatValue*100)/100)
switch xValue {
case _ where xValue > gate: print("large")
case _ where xValue < gate: print("little")
default: print("gate")
}
I want to make a float value as my Gate, and it works when I set gate such as 0.0 1.0 2.0, but it fails as 1.1, 1.2 etc.
My question is: is it really safe for 0,0 1.0, 1.5, 2.0 3.0, although these number pass the test?