It seems like you could easily move the isnan check outside the switch, so it doesn't need to be repeated for each one.