endianness and 64-bit machines

Discussion in 'C Programming' started by bob_jenkins, May 17, 2006.

  1. bob_jenkins

    bob_jenkins Guest

    When comparing strings, if a machine is big-endian, even if strings are
    not aligned, you can do some shifts then do word comparisons rather
    than byte-by-byte comparisons. Little-endian machines, though, haven't
    much choice but to read strings byte by byte during comparisons. The
    expense of those shifts is a little less than the cost of reading
    things byte-by-byte on 32-bit machines. But on 64-bit machines, the
    shift-and-compare-words approach is much faster than the byte-by-byte
    approach.

    So being big-endian has an advantage, and it's a bigger advantage for
    64-bit machines than it is for 32-bit machines. How much does this
    matter? I know databases spend a lot of time doing comparisons.
     
    bob_jenkins, May 17, 2006
    #1
    1. Advertisements

  2. bob_jenkins

    pete Guest

    Followup to:
     
    pete, May 17, 2006
    #2
    1. Advertisements

  3. When comparing strings, if a machine is big-endian, even if strings are
    I don't believe this. If you can do it with big-endian, you can do
    it with little-endian, until you find a mismatch, at which point
    you need to deal with figuring out whether the mismatch is beyond the
    string terminator or not (on big-endian, little-endian, and non-endian
    machines).
    This sounds like an unwarranted generalization, probably from a single
    64-bit machine.
    For a single very narrow purpose. Being big-endian also has a disadvantage
    for multi-precision addition/subtraction.
    Gordon L. Burditt
     
    Gordon Burditt, May 17, 2006
    #3
  4. bob_jenkins

    CBFalconer Guest

    Please preserve attributions for material you quote.

    Once more, the distribution of actual string sizes in a system
    comes into play. I assume, without more justification than
    instinct, that most strings are short, and thus the effort to
    switch between comparision of large entities and single chars is
    not going to be efficacious.

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
    More details at: <http://cfaj.freeshell.org/google/>
    Also see <http://www.safalra.com/special/googlegroupsreply/>
     
    CBFalconer, May 17, 2006
    #4
  5. if little endian is something like
    <----><---->
    a[0] a[1]
    i agree it is easier because the number can increase
    <----><----><---->
    a[0] a[1] a[2]

    in big endian i have to move the pointer
    <----><----><---->
    a[-1] a[0] a[1]

    so little endian is how represent number in a computer and
    0d=0b, 1d=1b, 2d==01b, 3d==11b,4d=001b, 5d=101b, 6d=011b etc
     
    RSoIsCaIrLiIoA, May 19, 2006
    #5
  6. bob_jenkins

    Malcolm Guest

    But it has the big advantage that Microsoft don't use it.
    After all, if we don't do everything we can to stop them, they might take
    over the world and force us all to store our bytes at the little end.
     
    Malcolm, May 20, 2006
    #6
  7. Newbie question:

    What does endianness mean? And what's a big-endian machine?


    Best regards / Med venlig hilsen
    Martin Jørgensen
     
    =?ISO-8859-1?Q?Martin_J=F8rgensen?=, May 20, 2006
    #7
  8. Richard Heathfield, May 20, 2006
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.