I am getting really confused now, if i have a signed value for example -634, what will the MSB and LSB of the number?
I am getting really confused now, if i have a signed value for example -634, what will the MSB and LSB of the number?
Assuming two's complement representation, -634 in 16 bits has the same bit pattern as 2**16 - 634 = 65536 - 634 = 64902 which in hex is 0xFD86. So the MSB is 0xFD and the LSB is 0x86. However, the order that the MSB and LSB are stored in memory depends on the endianness of your system. If it is little-endian then 0x86 will appear first (lower in memory) and 0xFD will appear after that.
A little inaccuracy saves tons of explanation. - H.H. Munro
Intel/AMD architecture are Little-Endian by default. There are compiler options in most compilers to change that.
See the Wikipedia article for more information.
It's apparently useless trying to help this person.
A little inaccuracy saves tons of explanation. - H.H. Munro
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
He's also asking the same or similar questions in multiple threads.
And his initial thread says he is writing the code for a "customer".
That customer is being ripped off since obviously doesn't know what he's doing.
And how do we get our cut of the profits?
A little inaccuracy saves tons of explanation. - H.H. Munro