stats.js: avoid floating point error causing potential infinite loop