Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void hex(int number)
- {
- long int temp;
- int i=-1,count,place;
- int binary_c[25];
- temp = binary(number); //convert the number to binary and assign it to temp
- do
- {
- temp /= 10000;
- i++;
- //PASSEDprintf("\nStage 1 Temp(%d)\n", temp);
- } while (temp);
- //convert the number of bunches of 4 numbers in binary.
- count = i;
- //transfert the number to count.
- temp = binary(number);
- //reset temp to the binary version
- ///PASSEdprintf("\nDebug temp(%d)", temp);
- //PASSEDprintf("\nDebug number of digits(%d)", count);
- do
- {
- binary_c[i] = (temp % 10000);
- //PASSEDprintf("\nStage 2 binary_c[%d]=%d\n",i, binary_c[i]);
- i--;
- //PASSEDprintf("\nStage 2 i(%d)\n",i);
- temp /= 10000;
- } while (i>=0);
- i = 0;
- for (i; i <= count; i++)
- {
- temp = 0;
- place = 1;
- do
- {
- temp += (binary_c[i] % 10)*place;
- place *= 2;
- binary_c[i]/= 10;
- //printf("\nStage 3 Temp(%d)\n", temp);
- //printf("\nStage 3 binary_c(%d)\n", binary_c[i]);
- //printf("\nStage 3 i(%d)\n", i);
- } while (binary_c[i]);
- if (temp < 10) printf("%c", temp + 48);
- else printf("%c", temp + 55);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement