ltoa.cc
mud++0.35/src/ltoa.cc · 1.5 KB
From the archive mud++0.35.tar.gz
Download the archive « Back to the archive contents
/*
....[@@@..[@@@..............[@.................. MUD++ is a written from
....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and
....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++.
....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing
....[@......[@..[@@@@@..[@@@@@.................. development project. All
................................................ contributions are welcome.
....Copyright(C).1995.Melvin.Smith.............. Enjoy.
------------------------------------------------------------------------------
Melvin Smith (aka Fusion) msmith@hom.net
MUD++ development mailing list mudpp@van.ml.org
------------------------------------------------------------------------------
ltoa.cpp
*/
#include <stdlib.h>
#include "config.h"
const char * ltoa( long x )
{
const char * str = "0123456789";
long rem;
static char buf[ 64 ];
char *ptr = buf + 63;
bool neg = 0;
if( x < 0 )
{
neg = true;
x = abs( x );
}
do
{
ptr--;
rem = x % 10;
*ptr = *(str + rem);
x /= 10;
}
while( x );
if( neg )
*--ptr = '-';
return ptr;
}
const char * ultoa( unsigned long x )
{
const char * str = "0123456789";
unsigned long rem;
static char buf[ 64 ];
char *ptr = buf + 63;
do
{
ptr--;
rem = (long)(x % 10);
*ptr = *(str + rem);
x /= 10;
}
while( x );
return ptr;
}