Thread: MSB and LSB of the signed value

  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    35

    MSB and LSB of the signed value

    I am getting really confused now, if i have a signed value for example -634, what will the MSB and LSB of the number?

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    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

  3. #3
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,111
    Quote Originally Posted by Clearner123 View Post
    I am getting really confused now, if i have a signed value for example -634, what will the MSB and LSB of the number?
    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.

  4. #4
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    It's apparently useless trying to help this person.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  5. #5
    Registered User
    Join Date
    Apr 2019
    Posts
    35
    Quote Originally Posted by john.c View Post
    It's apparently useless trying to help this person.
    Why do you think so, any reason?

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Clearner123 View Post
    Why do you think so, any reason?
    It is sometime very hard to tell the difference between a newbie and a "help vampire"!

    You are looking more like an "help vampire" than is considered good.

    Tim S.
    "...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

  7. #7
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unsigned vs. Signed?
    By Programmer_P in forum C++ Programming
    Replies: 4
    Last Post: 12-22-2009, 01:15 PM
  2. apache self signed ssl
    By ginoitalo in forum Tech Board
    Replies: 0
    Last Post: 09-04-2004, 07:41 AM
  3. signed/unsigned int
    By X PaYnE X in forum C Programming
    Replies: 3
    Last Post: 06-10-2004, 10:58 AM

Tags for this Thread