Binary Conversion anyone?

This is a discussion on Binary Conversion anyone? within the C Programming forums, part of the General Programming Boards category; Okay So I have this 100000 10100 11000 1000 0000 0000 0000 This section of the binary is assumed to ...

  1. #1
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73

    Binary Conversion anyone?

    Okay So I have this

    100000 10100 11000 1000 0000 0000 0000

    This section of the binary is assumed to be sign extended

    1000 0000 0000 0000

    so it turns to this

    0xFFFF8000

    why?!?

    and why is the value of that sign extended decimal number -2048?

    isn't it 2^15?

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Quote Originally Posted by NoobieGecko View Post
    Okay So I have this

    100000 10100 11000 1000 0000 0000 0000

    This section of the binary is assumed to be sign extended

    1000 0000 0000 0000

    so it turns to this

    0xFFFF8000

    why?!?
    My guess is because you have either defined or cast that portion of the field as signed.

    Todd
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    602
    What type of variable are you assigning this binary conversion to? If you look at the limits.h file this may help you decide what type(size) to assign your binary converted value to in decimal.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    What does the source code look like?

  5. #5
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    oh i just wanted to know how sign extension works, it's actually a mips instruction

    loadbyte

    lb $24,-2048($20)

    my guess is that "load byte" has to have a sign extended immediate

    so 1000 0000 0000 0000 == 0xffff8000... i guess ~_~

    just studying for a midterm :O

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. binary decimal conversion
    By eerok in forum C Programming
    Replies: 2
    Last Post: 01-24-2006, 08:51 PM
  3. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 10:31 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21