static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength){ static char bin[64]; unsigned int i=0; while (Dec > 0) { bin[32+i++] = (Dec & 1 > 0) ? '1' : '0'; Dec = Dec >> 1; } for (unsigned int j = 0; j< bitLength; j++) { if (j >= bitLength - i) { bin[j] = bin[ 31 + i - (j - (bitLength - i)) ]; }else { bin[j] = '0'; } } bin[bitLength] = '\0'; return bin; }