Hallo,

ich hab im Forum eine für mich sehr brauchbare Funktion gefunden und auch erfolgreich in Verwendung! Nur hab ich leider keine Ahnung warum das so funktioniert wie es funktioniert

Könnte jmd die Funktion evtl. mit Kommentaren versehen - "Deppensicher" - also so dass ich es auch verstehe

THX

Code:
void float2string(float value, int decimal, char* valuestring) 
{ 
    int neg = 0;    
    char tempstr[20]; 
    int i = 0;    
    int j = 0;    
    int c;    
    long int val1, val2; 
    char* tempstring; 
    tempstring = valuestring; 
    if (value < 0) {neg = 1; value = -value;} 
    for (j=0; j < decimal; j++) {value = value * 10;} 
    val1 = (value * 2); 
    val2 = (val1 / 2) + (val1 % 2); 
    while (val2 !=0) { 
        if ((decimal > 0) && (i == decimal)) { 
            tempstr[i] = (char)(0x2E); //0x2E = Punkt 
            i++; 
        } 
        else { 
            c = (val2 % 10); 
            tempstr[i] = (char) (c + 0x30); //0x30 = Null 
            val2 = val2 / 10; 
            i++; 
        } 
    } 
    if (neg) { 
        *tempstring = '-'; 
        tempstring++; 
    } 
    i--; 
    for (;i > -1;i--) { 
        *tempstring = tempstr[i]; 
        tempstring++; 
    } 
    *tempstring = '\0'; 
}