Gaudi Framework, version v22r0

Home   Generated: 9 Feb 2011

xtoa.cpp File Reference

#include <stdlib.h>
#include <limits.h>
#include "GaudiKernel/xtoa.h"
Include dependency graph for xtoa.cpp:

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;    /* 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 }

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Wed Feb 9 16:28:15 2011 for Gaudi Framework, version v22r0 by Doxygen version 1.6.2 written by Dimitri van Heesch, © 1997-2004