Funktion „calculate_units_down“ (C)

void calculate_units_down( long *a, int c, long u, long *b ) {
    
    /* USE:
    
    long a[4] = { // dividend array
    
    1000, // ms >> ss
    60, // ss >> mm
    60, // mm >> hh
    24 // hh >> dd
    
    int c = 4; // number of elements
    
    long u = 1000000000; // start unit
    
    long b[5]; // result array
    
    */
    
    b[0] = u;
    
    int i;
    
    for ( i=0; i<c; i++ ) {
        
        b[c+1] = b[c] / 1000; // e.g. ss = ms / 1000
        b[c] = b[c] % 1000; // e.g. ms = ms % 1000
        
    } // while
    
} // function
Veröffentlicht unter Beta | Verschlagwortet mit ,