Endianness - Is this correct?

This is a discussion on Endianness - Is this correct? within the Tech Board forums, part of the Community Boards category; Hi, I was just reading some article when I stumbled across this. It's making me question my knowledge of endianness. ...

  1. #1
    Registered User Tommo's Avatar
    Join Date
    Jun 2007
    Location
    Scotland
    Posts
    101

    Endianness - Is this correct?

    Hi, I was just reading some article when I stumbled across this. It's making me question my knowledge of endianness. It says:

    Code:
    For example lets say we are going to store a 2-byte number
       in memory say the value is (in hex) 0x0203
    
    
       First this is how the value is stored on a big-endian machine:
    
                        ___________
                       | 02  | 03  |
                       |_____|_____| 
            address:    0       1
    
    
       And here is the same value on a little-endian machine:
    
                       ___________
                      |03   | 02  |
                      |_____|_____|
           address:    1       0
    Is this correct? Shouldn't the latter either be:
    Code:
                      ___________
                      |03   | 02  |
                      |_____|_____|
           address:    0       1
    or
    Code:
                      ___________
                      |02   | 03  |
                      |_____|_____|
           address:    1       0

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,159
    You're right, it's wrong. The address doesn't change, only the order of values does. Your first possibility is the right one.

  3. #3
    Registered User Tommo's Avatar
    Join Date
    Jun 2007
    Location
    Scotland
    Posts
    101
    thanks brewbuck

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linux for GNU/Linux is not correct?
    By password636 in forum Linux Programming
    Replies: 8
    Last Post: 03-31-2009, 08:30 PM
  2. Changing endianness
    By slippy in forum C++ Programming
    Replies: 9
    Last Post: 03-26-2009, 01:17 PM
  3. Is this correct : passing strings?
    By socket in forum C Programming
    Replies: 15
    Last Post: 11-25-2008, 01:03 PM
  4. Replies: 1
    Last Post: 05-26-2004, 12:58 AM
  5. Why I couldn't see the correct format of a file?
    By miketv in forum C Programming
    Replies: 2
    Last Post: 01-23-2002, 09:59 PM

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