lib/c.c
/* set 10 digits (32bit) without div */
set 10 digits (32bit) without div
set 10 digits ( 32bit ) without div
void __str_base10(char *pb, int val)
{
    int neg = 0;
    if (val < 0) {
        neg = 1;
        val = -val;
    }
    while (val >= 1000000000) {
        val -= 1000000000;
        pb[0]++;
    }
    while (val >= 100000000) {
        val -= 100000000;
        pb[1]++;
    }
    while (val >= 10000000) {
        val -= 10000000;
        pb[2]++;
    }
    while (val >= 1000000) {
        val -= 1000000;
        pb[3]++;
    }
    while (val >= 100000) {
        val -= 100000;
        pb[4]++;
    }
    while (val >= 10000) {
        val -= 10000;
        pb[5]++;
    }
    while (val >= 1000) {
        val -= 1000;
        pb[6]++;
    }
    while (val >= 100) {
        val -= 100;
        pb[7]++;
    }
    while (val >= 10) {
        val -= 10;
        pb[8]++;
    }
    while (val >= 1) {
        val -= 1;
        pb[9]++;
    }
    if (neg == 1) {
        int c = 0;
        while (pb[c] == '0')
            c++;
        if (c > 0)
            pb[c - 1] = '-';
    }
}
void __str_base10 ( char * pb , int val ) { int neg = 0 ; if ( val < 0 ) { neg = 1 ; val = - val ; } while ( val >= 1000000000 ) { val -= 1000000000 ; pb [ 0 ] ++ ; } while ( val >= 100000000 ) { val -= 100000000 ; pb [ 1 ] ++ ; } while ( val >= 10000000 ) { val -= 10000000 ; pb [ 2 ] ++ ; } while ( val >= 1000000 ) { val -= 1000000 ; pb [ 3 ] ++ ; } while ( val >= 100000 ) { val -= 100000 ; pb [ 4 ] ++ ; } while ( val >= 10000 ) { val -= 10000 ; pb [ 5 ] ++ ; } while ( val >= 1000 ) { val -= 1000 ; pb [ 6 ] ++ ; } while ( val >= 100 ) { val -= 100 ; pb [ 7 ] ++ ; } while ( val >= 10 ) { val -= 10 ; pb [ 8 ] ++ ; } while ( val >= 1 ) { val -= 1 ; pb [ 9 ] ++ ; } if ( neg == 1 ) { int c = 0 ; while ( pb [ c ] == ' ' ) c ++ ; if ( c > 0 ) pb [ c - 1 ] = ' ' ; } }
set 10 digits (32bit) without div
set 10 digits ( 32bit ) without div