Answer the question
In order to leave comments, you need to log in
How to display each byte of an int value?
It was necessary to output each byte of an int value.
int value = 257;
for (int i = 0; i < sizeof(int); i++)
printf("%hhd ", *(((char *) &value) + i)); // 1 1 0 0
1234
, then in my case the output will be equal to-46 4 0 0
Answer the question
In order to leave comments, you need to log in
1. char is a signed type. Use unsigned char, and preferably std::byte if available to you.
2. check the format string.
1234 in 4D2 hexadecimal system.
The low byte is equal to D2, in binary it is: 1101 0010
As you can see, the high bit is set to 1 - which means that if this is a signed number, then it is negative and encoded in two's complement . It remains only to decompose D2 in an additional code and get -46 - this is the result for you and printed f.
try overriding the getItemId() method on the adapter
@Override
public long getItemId(int position) {
return <ваш_правильный_id>;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question