![]() |
|
|
Generated: 8 Jan 2009 |
#include <stdlib.h>
#include <limits.h>
#include "GaudiKernel/xtoa.h"

Go to the source code of this file.
Functions | |
| static void __cdecl | xtoa (unsigned long val, char *buf, unsigned radix, int is_neg) |
| char *__cdecl | _itoa (int val, char *buf, int radix) |
| char *__cdecl | _ltoa (long val, char *buf, int radix) |
| char *__cdecl | _ultoa (unsigned long val, char *buf, int radix) |
| char* __cdecl _itoa | ( | int | val, | |
| char * | buf, | |||
| int | radix | |||
| ) |
| char* __cdecl _ltoa | ( | long | val, | |
| char * | buf, | |||
| int | radix | |||
| ) |
| char* __cdecl _ultoa | ( | unsigned long | val, | |
| char * | buf, | |||
| int | radix | |||
| ) |
| static void __cdecl xtoa | ( | unsigned long | val, | |
| char * | buf, | |||
| unsigned | radix, | |||
| int | is_neg | |||
| ) | [static] |
Definition at line 39 of file xtoa.cpp.
00039 { 00040 char *p; /* pointer to traverse string */ 00041 char *firstdig; /* pointer to first digit */ 00042 char temp; /* temp char */ 00043 unsigned digval; /* value of digit */ 00044 00045 p = buf; 00046 00047 if (is_neg) { 00048 /* negative, so output '-' and negate */ 00049 *p++ = '-'; 00050 val = (unsigned long)(-(long)val); 00051 } 00052 00053 firstdig = p; /* save pointer to first digit */ 00054 00055 do { 00056 digval = (unsigned) (val % radix); 00057 val /= radix; /* get next digit */ 00058 00059 /* convert to ascii and store */ 00060 if (digval > 9) 00061 *p++ = (char) (digval - 10 + 'a'); /* a letter */ 00062 else 00063 *p++ = (char) (digval + '0'); /* a digit */ 00064 } while (val > 0); 00065 00066 /* We now have the digit of the number in the buffer, but in reverse 00067 order. Thus we reverse them now. */ 00068 00069 *p-- = '\0'; /* terminate string; p points to last digit */ 00070 00071 do { 00072 temp = *p; 00073 *p = *firstdig; 00074 *firstdig = temp; /* swap *p and *firstdig */ 00075 --p; 00076 ++firstdig; /* advance to next two digits */ 00077 } while (firstdig < p); /* repeat until halfway */ 00078 }