For positive period, the returned value is in the range [0,1).
phase(7, 4) = 0.75
phase(-1000.5, 2.5) = 0.8
phase(-3300, 33) = 0