Protecting against 0

I have a sneaking suspicion that this is NOT the best way to do this, i guess we’ll see when I press play again. I am using a switch statement to escape (with “return;”) escaping the function if period = 0 and stopping any oscillation from being set. My thought is that if the designer is setting to 0 they are hoping for no oscillation.

Ok, i had the right idea i guess. Doing it this way doesn’t throw the same console error as if statement (not sure why, i’m sure it’s more obvious to a better programmer), but I imagine it’s better to do if and compare to epsilon than what I am doing?

Privacy & Terms