Like Tree1Likes
  • 1 Post By iMalc

memory

This is a discussion on memory within the C Programming forums, part of the General Programming Boards category; In which format does C store an integer in main memory of the computer (RAM).(Given that is uses two bytes ...

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

    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
    395
    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,425
    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%.

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    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.
    progmateur likes this.
    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


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