Fix infinity printing patch to compile on MSVC, extend for NaNs and add test coverage