Thread: ASCII and "big endian"

  1. #16
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Just out of curiosity, is Little Endian more efficient for a CPU than Big Endian?

    I would expect math operations on Little Endian to be easier and faster than on Big Endian since all bits are read from right to left, instead of reading left 8 bits, then jump forward (right) 16 bits and read another 8 bits... Big Endian sort of looks like bit fragmentation to me.

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    To the CPU, it doesn't matter (otherwise I don't know if endianness would exist). It's just electricity - one or zero.

  3. #18
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by Elysia View Post
    Yep, everyone is picking on me today
    But I already demonstrated I was wrong and edited the first post to match.
    No, it's just at the time I posted, the other four posts above weren't there yet.

    Endianness is not so much about efficiency, though historically little endian allowed a shortcut when it came to incrementing an int value. You could simply increment the first byte, and that would usually by enough. Or something like that so I've heard.

    Both have advantages, they're just different.
    In little endian, you can convert an int pointer to a short pointer or byte pointer to the same value without the memory address having to be altered. You make the type bigger by adding more bytes at the end.
    However in big-endian, the value as an int appears the same way when you view the bytes by themselves, so debugging can be much easier.
    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"

  4. #19
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by iMalc View Post
    In little endian, you can convert an int pointer to a short pointer or byte pointer to the same value without the memory address having to be altered.
    Actually, I think that's Big Endian that has that benefit, because the least significant byte is on the left.

    Maybe they should combine the advantages of the two and have Reverse Left Endian. Just have the least significant BIT start at the left and then everything higher can go to the right.

  5. #20
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by cpjust View Post
    Actually, I think that's Big Endian that has that benefit, because the least significant byte is on the left.

    Maybe they should combine the advantages of the two and have Reverse Left Endian. Just have the least significant BIT start at the left and then everything higher can go to the right.
    HUH? What is this completely insane left/right stuff?

    What makes you think the CPU has any concept of "left," why would it matter, what does it have to do with anything?

    Or am I missing some sort of joke here?

  6. #21
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by brewbuck View Post
    HUH? What is this completely insane left/right stuff?

    What makes you think the CPU has any concept of "left," why would it matter, what does it have to do with anything?

    Or am I missing some sort of joke here?
    Oops, I meant "Reverse Little Endian".

    But to put it another way: Big Endian lets you write hex values from left to right, but the bits are not all sequencial, and with Little Endian the bits are sequencial, but the hex value is read right to left. So if you combine Little & Big Endian, you could have the bits sequencial and still read the hex bytes from left to right.

  7. #22
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by cpjust View Post
    Oops, I meant "Reverse Little Endian".

    But to put it another way: Big Endian lets you write hex values from left to right, but the bits are not all sequencial, and with Little Endian the bits are sequencial, but the hex value is read right to left. So if you combine Little & Big Endian, you could have the bits sequencial and still read the hex bytes from left to right.
    I think you are missing the point. The CPU has no idea of spatial organization of bits. Talking about left and right is meaningless. The issue with endianness is whether the least significant byte goes at the lowest address or the highest address. We're talking about low and high, not right and left. The idea that the lowest address is somehow "left of" higher addresses is just a human delusion.

  8. #23
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by cpjust View Post
    Actually, I think that's Big Endian that has that benefit, because the least significant byte is on the left.

    Maybe they should combine the advantages of the two and have Reverse Left Endian. Just have the least significant BIT start at the left and then everything higher can go to the right.
    No, I had it right.
    I programmed on 680x0 (big-endian) Macs for many years, then switched to programming x86 (little-endian) PCs for many more years. It is definitely as I said.

    As brewbuck states, there is no concept of the direction of the bits within each byte.
    There is no way to combine the bennefits of both either.
    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. Explain this whole "Big Bang" thing to me
    By Govtcheez in forum A Brief History of Cprogramming.com
    Replies: 65
    Last Post: 01-14-2005, 12:37 PM
  2. Exception to the "Big 3"?
    By Cat in forum C++ Programming
    Replies: 4
    Last Post: 06-08-2003, 09:08 AM