xtoa.cpp File Reference
#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) |
Function Documentation
| char* __cdecl _itoa |
( |
int |
val, |
|
|
char * |
buf, |
|
|
int |
radix | |
|
) |
| | |
Definition at line 83 of file xtoa.cpp.
00083 {
00084 if (radix == 10 && val < 0)
00085 xtoa((unsigned long)val, buf, radix, 1);
00086 else
00087 xtoa((unsigned long)(unsigned int)val, buf, radix, 0);
00088 return buf;
00089 }
| char* __cdecl _ltoa |
( |
long |
val, |
|
|
char * |
buf, |
|
|
int |
radix | |
|
) |
| | |
Definition at line 91 of file xtoa.cpp.
00091 {
00092 xtoa((unsigned long)val, buf, radix, (radix == 10 && val < 0));
00093 return buf;
00094 }
| char* __cdecl _ultoa |
( |
unsigned long |
val, |
|
|
char * |
buf, |
|
|
int |
radix | |
|
) |
| | |
Definition at line 96 of file xtoa.cpp.
00096 {
00097 xtoa(val, buf, radix, 0);
00098 return buf;
00099 }
| 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;
00041 char *firstdig;
00042 char temp;
00043 unsigned digval;
00044
00045 p = buf;
00046
00047 if (is_neg) {
00048
00049 *p++ = '-';
00050 val = (unsigned long)(-(long)val);
00051 }
00052
00053 firstdig = p;
00054
00055 do {
00056 digval = (unsigned) (val % radix);
00057 val /= radix;
00058
00059
00060 if (digval > 9)
00061 *p++ = (char) (digval - 10 + 'a');
00062 else
00063 *p++ = (char) (digval + '0');
00064 } while (val > 0);
00065
00066
00067
00068
00069 *p-- = '\0';
00070
00071 do {
00072 temp = *p;
00073 *p = *firstdig;
00074 *firstdig = temp;
00075 --p;
00076 ++firstdig;
00077 } while (firstdig < p);
00078 }