Thread: memory

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    77

    memory

    In which format does C store an integer in main memory of the computer (RAM).(Given that is uses two bytes for integer datatype)

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    396
    The endianness depends on the CPU. For instance, the low order byte first, then the high order next on an intel architecture.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The representation in memory of an integer (in fact, of any type) is implementation dependent. It varies between compilers, host systems, etc.

    Also, it is implementation dependent whether an integer datatype is sized at two bytes. Four bytes is also common in practice.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by progmateur View Post
    In which format does C store an integer in main memory of the computer (RAM).(Given that is uses two bytes for integer datatype)
    In binary

    You used the word "which", implying that there were was a common understanding of the options from which to pick from. However, you'd need to supply those options in this case.

    If you were talking about endianness, then that isn't determined by the C language; It's determined by the system that the code is compiled for.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2012, 04:28 AM
  2. Dynamic memory and realloc(), freeing memory
    By C_Sparky in forum C Programming
    Replies: 6
    Last Post: 10-06-2010, 07:55 PM
  3. Replies: 12
    Last Post: 04-11-2010, 07:14 AM
  4. Allocate memory inside allocated memory block?
    By Heidi_Nayak in forum C Programming
    Replies: 14
    Last Post: 04-15-2009, 04:19 PM
  5. Replies: 2
    Last Post: 09-28-2006, 01:06 PM

Tags for this Thread