1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS system libraries 4 * FILE: lib/sdk/crt/string/witoa.c 5 * PURPOSE: converts a integer to ascii 6 * PROGRAMER: 7 * UPDATE HISTORY: 8 * 1995: Created 9 * 1998: Added ltoa by Ariadne 10 * 2006 : replace all api in this file to wine cvs 2006-05-21 11 */ 12 /* */ 13 #include <precomp.h> 14 15 /* 16 * @implemented 17 * copy _i64toa from wine cvs 2006 month 05 day 21 18 */ 19 char* _i64toa(__int64 value, char* string, int radix) 20 { 21 ULONGLONG val; 22 int negative; 23 char buffer[65]; 24 char *pos; 25 int digit; 26 27 if (value < 0 && radix == 10) { 28 negative = 1; 29 val = -value; 30 } else { 31 negative = 0; 32 val = value; 33 } /* if */ 34 35 pos = &buffer[64]; 36 *pos = '\0'; 37 38 do { 39 digit = val % radix; 40 val = val / radix; 41 if (digit < 10) { 42 *--pos = '0' + digit; 43 } else { 44 *--pos = 'a' + digit - 10; 45 } /* if */ 46 } while (val != 0L); 47 48 if (negative) { 49 *--pos = '-'; 50 } /* if */ 51 52 memcpy(string, pos, &buffer[64] - pos + 1); 53 return string; 54 } 55 56 57 /* 58 * @implemented 59 */ 60 char* _ui64toa(unsigned __int64 value, char* string, int radix) 61 { 62 char buffer[65]; 63 char *pos; 64 int digit; 65 66 pos = &buffer[64]; 67 *pos = '\0'; 68 69 do { 70 digit = value % radix; 71 value = value / radix; 72 if (digit < 10) { 73 *--pos = '0' + digit; 74 } else { 75 *--pos = 'a' + digit - 10; 76 } /* if */ 77 } while (value != 0L); 78 79 memcpy(string, pos, &buffer[64] - pos + 1); 80 return string; 81 } 82