Handle NaN / +Inf / -Inf in range evaluation (fixes #606).