00001
00002
00003
00004
00005 #include "StdAfx.h"
00006
00007 #include "IntToString.h"
00008
00009 void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base)
00010 {
00011 if (base < 2 || base > 36)
00012 {
00013 *s = L'\0';
00014 return;
00015 }
00016 char temp[72];
00017 int pos = 0;
00018 do
00019 {
00020 int delta = (int)(value % base);
00021 temp[pos++] = (delta < 10) ? ('0' + delta) : ('a' + (delta - 10));
00022 value /= base;
00023 }
00024 while (value != 0);
00025 do
00026 *s++ = temp[--pos];
00027 while(pos > 0);
00028 *s = '\0';
00029 }
00030
00031 void ConvertUInt64ToString(UInt64 value, wchar_t *s)
00032 {
00033 wchar_t temp[32];
00034 int pos = 0;
00035 do
00036 {
00037 temp[pos++] = L'0' + (int)(value % 10);
00038 value /= 10;
00039 }
00040 while (value != 0);
00041 do
00042 *s++ = temp[--pos];
00043 while(pos > 0);
00044 *s = L'\0';
00045 }
00046
00047 void ConvertInt64ToString(Int64 value, char *s)
00048 {
00049 if (value < 0)
00050 {
00051 *s++ = '-';
00052 value = -value;
00053 }
00054 ConvertUInt64ToString(value, s);
00055 }
00056
00057 void ConvertInt64ToString(Int64 value, wchar_t *s)
00058 {
00059 if (value < 0)
00060 {
00061 *s++ = L'-';
00062 value = -value;
00063 }
00064 ConvertUInt64ToString(value, s);
00065 }