uitos: Fix off-by-one error bug

This commit is contained in:
Tatsuhiro Tsujikawa 2013-04-29 23:53:23 +09:00
parent 6b7a51d5e0
commit 549dd5b2a7

View File

@ -193,7 +193,7 @@ std::string uitos(T n, bool comma = false)
--i;
for(int j = 0; n; --i, ++j, n /= 10) {
res[i] = (n%10) + '0';
if(comma && (j+1)%3 == 0) {
if(comma && i > 1 && (j+1)%3 == 0) {
res[--i] = ',';
}
}