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