Reuse code in isXNumber() to avoid duplication and unneeded computations

This reduces code duplication, eliminates unneeded computation, fixes irrelevant comments, gets rid of irrelevant variable names.