rlm@1: // Common/IntToString.cpp rlm@1: rlm@1: #include "StdAfx.h" rlm@1: rlm@1: #include "IntToString.h" rlm@1: rlm@1: void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base) rlm@1: { rlm@1: if (base < 2 || base > 36) rlm@1: { rlm@1: *s = '\0'; rlm@1: return; rlm@1: } rlm@1: char temp[72]; rlm@1: int pos = 0; rlm@1: do rlm@1: { rlm@1: int delta = (int)(value % base); rlm@1: temp[pos++] = (char)((delta < 10) ? ('0' + delta) : ('a' + (delta - 10))); rlm@1: value /= base; rlm@1: } rlm@1: while (value != 0); rlm@1: do rlm@1: *s++ = temp[--pos]; rlm@1: while (pos > 0); rlm@1: *s = '\0'; rlm@1: } rlm@1: rlm@1: void ConvertUInt64ToString(UInt64 value, wchar_t *s) rlm@1: { rlm@1: wchar_t temp[32]; rlm@1: int pos = 0; rlm@1: do rlm@1: { rlm@1: temp[pos++] = (wchar_t)(L'0' + (int)(value % 10)); rlm@1: value /= 10; rlm@1: } rlm@1: while (value != 0); rlm@1: do rlm@1: *s++ = temp[--pos]; rlm@1: while (pos > 0); rlm@1: *s = L'\0'; rlm@1: } rlm@1: rlm@1: void ConvertInt64ToString(Int64 value, char *s) rlm@1: { rlm@1: if (value < 0) rlm@1: { rlm@1: *s++ = '-'; rlm@1: value = -value; rlm@1: } rlm@1: ConvertUInt64ToString(value, s); rlm@1: } rlm@1: rlm@1: void ConvertInt64ToString(Int64 value, wchar_t *s) rlm@1: { rlm@1: if (value < 0) rlm@1: { rlm@1: *s++ = L'-'; rlm@1: value = -value; rlm@1: } rlm@1: ConvertUInt64ToString(value, s); rlm@1: }