Not NAN-related, and don't know about the performance of this code, but surely it must have more overhead than `sprintf()` or equivalent?