Shadowrun: Awakened 29 September 2011 - Build 871
linuxadd.cpp
Go to the documentation of this file.
00001 #include "linuxadd.h"
00002 #include <string>
00003 
00004 
00005 char* itoa( int value, char* result, int base ) {
00006     
00007     // check that the base if valid
00008     if (base < 2 || base > 16) { *result = 0; return result; }
00009     char* out = result;
00010     int quotient = value;
00011     do {
00012         *out = "0123456789abcdef"[ std::abs( quotient % base ) ];
00013         ++out;
00014         quotient /= base;
00015     } while ( quotient );
00016     
00017 
00018     
00019     // Only apply negative sign for base 10
00020     
00021     if ( value < 0 && base == 10) *out++ = '-';
00022     std::reverse( result, out );
00023     *out = 0;
00024     return result;
00025 }
00026 

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net