Answer the question
In order to leave comments, you need to log in
How to correctly translate from 16CC to 2CC?
Hello. I need to enter a number in 16CC. I do it like this scanf("%x", &read);
:
But now I need to determine how many bits it takes to store the number in memory.
Therefore, I need to convert the number to 2CC. How can this be done with just one function?
Answer the question
In order to leave comments, you need to log in
Why translate to determine a significant number of bits?
unsigned long long number;
std::cin >> std::hex >> number;
int bits = 0;
while(number != 0) {
++bits;
number >>= 1;
}
In addition to MiiNiPaa , I will say that all your numbers are already stored in binary, today's popular calc. equipment does not work with other systems. Another thing is in which SS you want to display these numbers on the screen / in a file, in general - convert them into a human-readable string. So the whole question boils down to reading help on printf arguments or on C++ stream directives.
How to correctly translate from 16CC to 2CC?
0 - 0000
1 - 0001
2 - 0010
3 - 0011
4 - 0100
5 - 0101
6 - 0110
7 - 0111
8 - 1000
9 - 1001
A - 1010
B - 1011
C - 1100
D - 1101
E - 1110
F - 1111
1A - 0001 1010
AB - 1010 1011
FF - 1111 1111
ABFEC - 1010 1011 1111 1110 1100
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question