Results 1 to 2 of 2

Thread: Big ending on little ending cpu

  1. #1
    Join Date
    Jun 2008
    Thanked 23 Times in 16 Posts

    Question Big endian on little endian cpu


    I have following problem on a little endian cpu:

    I have ranges of Uint saved in little endian and several millions of numbers Uint saved in big endian. Now I want to know if these numbers are matching into the ranges. Is there a more performant way to do this except converting each number into little endian and then compare?

    E.g. Converting the limits of the ranges in some format which can be used to compare with the big ending number? So that the conversation during the test if the big endian number is inside the range limits can be saved?

    Thx in advance
    Last edited by thometal; 29th September 2016 at 04:10.

  2. #2
    Programmer michael maniscalco's Avatar
    Join Date
    Apr 2007
    Boston, Massachusetts, USA
    Thanked 95 Times in 32 Posts
    I'm sure that you *could* do it by defining a series of ranges in little endian that would serve as the same filter as the range in big endian. But I would think that this would be a much larger performance hit than simply converting the big endian numbers into little endian once. Converting several million big endian integers to little endian should have a virtually immeasurable impact on performance.

    You could also store the big endian data in contiguous memory and then simply reverse the data. That would give you the big endian values in little endian format but in reverse order of occurrence, no?

    something like:
    std::vector<int32_t> bigEndianValues;
    std::reverse((int8_t *), (int8_t *) * sizeof(int32_t) * bigEndianValues.size());

    But that's probably no faster than doing:

    for (auto & e : bigEndianValues)
    e = ntohl(e);

Similar Threads

  1. sorting rotations of a string - detecting an never-ending comparision
    By just a worm in forum The Off-Topic Lounge
    Replies: 9
    Last Post: 5th June 2015, 18:53
  2. Forum's Notifications ending up in spam/junk folders
    By Scientist in forum The Off-Topic Lounge
    Replies: 3
    Last Post: 11th December 2009, 02:15
  3. I volunteer for some big dictionary test
    By SvenBent in forum Data Compression
    Replies: 18
    Last Post: 8th June 2008, 23:59
  4. Fast decompression of big files
    By SvenBent in forum Forum Archive
    Replies: 16
    Last Post: 8th March 2008, 20:17
  5. Start of another BIG and really real Benchmark
    By Simon Berger in forum Forum Archive
    Replies: 31
    Last Post: 15th November 2007, 17:18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts