Read carefully before answering the following!
Computers "talk" only binary language then each variable, etc. and two to a set of 1's and 0 place in ram.
My question is' simple, as you can convert a list of bits in a decimal number without using types like int, double, etc.?
The conversion from decimal to binary number and a 'very simple if you work directly with the bits of the variable:
Note: In the above code bits and a bitset.
Regarding the conversion to decimal a possible solution would be to use an algorithm of the type:
However, such a solution requires that the number is not bigger than an int, a long or long long (note: the example works only with int), otherwise an overflow error.
Now suppose we have an array of 512 bits or more 'items. This is the number that you could not calculate with the aforementioned method because 'greatly exceeds the capacity of all numeric types, that algorithm could be used to make the conversion?
Initially I thought I could use the shakes which then go on to build a class that performs this work, however, it gives me the idea of being a further complication of the work with even the pitiful performance.
Computers "talk" only binary language then each variable, etc. and two to a set of 1's and 0 place in ram.
My question is' simple, as you can convert a list of bits in a decimal number without using types like int, double, etc.?
The conversion from decimal to binary number and a 'very simple if you work directly with the bits of the variable:
Code
for (int i = 0; i <sizeof (unsigned) * 8; i ++)
{
bits [i] = (v >> i) & 1;
} // The code works if and only if the length of the array of bits and 'higher (or equal to) 32Note: In the above code bits and a bitset.
Regarding the conversion to decimal a possible solution would be to use an algorithm of the type:
Code
for(int i=0;i<32;i++)
{
myInt += bits[i] * pow(2,i);
}However, such a solution requires that the number is not bigger than an int, a long or long long (note: the example works only with int), otherwise an overflow error.
Now suppose we have an array of 512 bits or more 'items. This is the number that you could not calculate with the aforementioned method because 'greatly exceeds the capacity of all numeric types, that algorithm could be used to make the conversion?
Initially I thought I could use the shakes which then go on to build a class that performs this work, however, it gives me the idea of being a further complication of the work with even the pitiful performance.

