Results 1 to 2 of 2

Thread: Big ending on little ending cpu

  1. #1
    Member
    Join Date
    Jun 2008
    Location
    G
    Posts
    377
    Thanks
    26
    Thanked 23 Times in 16 Posts

    Question Big endian on little endian cpu

    Hi,

    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 03:10.

  2. #2
    Programmer michael maniscalco's Avatar
    Join Date
    Apr 2007
    Location
    Boston, Massachusetts, USA
    Posts
    140
    Thanks
    26
    Thanked 94 Times in 31 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 *)bigEndianValues.data(), (int8_t *)bigEndianValues.data() * 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, 17: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, 01:15
  3. I volunteer for some big dictionary test
    By SvenBent in forum Data Compression
    Replies: 18
    Last Post: 8th June 2008, 22:59
  4. Fast decompression of big files
    By SvenBent in forum Forum Archive
    Replies: 16
    Last Post: 8th March 2008, 19:17
  5. Start of another BIG and really real Benchmark
    By Simon Berger in forum Forum Archive
    Replies: 31
    Last Post: 15th November 2007, 16: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
  •