Using the following libraries only:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <math.h>
I need a efficient way to convert a decimal to a hex in the following:
int iteration (arguments...) {
//calculate the number of iterations for this function to do something
return iterations; //returns in decimal, e.g. 70
}
char hello = (iteration in hex);
What would the code for (iteration in hex) look like?
I have heaps of loops so there would be a lot of converting to hex, the more efficient the better (though I’m pretty sure that there’s a function to do this).
There is no such thing like returning an
intas a decimal.inthave an internal representation in C that have not much to do with our way of representing numbers for humans.In C you can assign numbers that are written in octal, decimal or hexadecimal notation to an
int. It then contains the “abstract” number so to speak.