mathematics: Don't use division by zero in NAN/INFINITY macros