Shadowrun: Awakened 29 September 2011 - Build 871
Functions
linuxadd.cpp File Reference
#include "linuxadd.h"
#include <string>
Include dependency graph for linuxadd.cpp:

Go to the source code of this file.

Functions

char * itoa (int value, char *result, int base)

Function Documentation

char* itoa ( int  value,
char *  result,
int  base 
)

Definition at line 5 of file linuxadd.cpp.

                                                {
    
    // check that the base if valid
    if (base < 2 || base > 16) { *result = 0; return result; }
    char* out = result;
    int quotient = value;
    do {
        *out = "0123456789abcdef"[ std::abs( quotient % base ) ];
        ++out;
        quotient /= base;
    } while ( quotient );
    

    
    // Only apply negative sign for base 10
    
    if ( value < 0 && base == 10) *out++ = '-';
    std::reverse( result, out );
    *out = 0;
    return result;
}

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