Thread: Negative int's in Hex?

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    30

    Negative int's in Hex?

    If the range of an int is -32768 to 32767, then what is this range in hex? Is it possible to represent negative values in hex?

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    According to printf()'s %x conversion you can't. This is what I get:

    -32768 = 8000
    32767 = 7fff

    I think the way it represents negative numbers also has to do with whether the system you're on uses two's complement, one's complement, or sign magnitude to indicate negative values.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    hello, internet!

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    30
    Oh, very helpful (re: compliments) - thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ascii to hex and hex to Ascii
    By beon in forum C Programming
    Replies: 1
    Last Post: 12-26-2006, 06:37 AM
  2. Hex Editing help and information please...
    By SG57 in forum C Programming
    Replies: 9
    Last Post: 06-25-2006, 12:30 AM
  3. Replies: 11
    Last Post: 03-24-2006, 11:26 AM
  4. converting hex to dec
    By jibbles in forum C Programming
    Replies: 20
    Last Post: 08-07-2004, 11:40 PM
  5. how to handle integer overflow in C
    By kate1234 in forum C Programming
    Replies: 8
    Last Post: 04-23-2003, 12:20 PM