Thread: bitset + memcpy

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    486
    Nothing is reversed. Take the difference between English and Hebrew writing systems. English goes left to right, Hebrew goes right to left. This doesn't mean that one of them is "reversed," it means they are different. To say that Hebrew, for instance, is written "backwards" is no more justifiable than saying English is written backwards.
    That's jsut splitting hairs. What I meant was that, comparing an array with n elements to a bitset with nelements, the nth element is the last one in the array, but the first (leftmost?) one in the bitset.

    There is ONLY "most signficant" and "least significant."
    Fair enough - on a little endian system, the the MSB on the left or the right?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by KBriggs View Post
    That's jsut splitting hairs. What I meant was that, comparing an array with n elements to a bitset with nelements, the nth element is the last one in the array, but the first (leftmost?) one in the bitset.



    Fair enough - on a little endian system, the the MSB on the left or the right?
    >> That's jsut splitting hairs.

    No, it was concise. To say that endianness is "reversed" is misleading and incorrect. The bytes are swapped - nothing more.

    >> Fair enough - on a little endian system, the the MSB on the left or the right?

    Strictly speaking, neither! In programming, "left" and "right" generally refer to bit positions, and are endian-neutral terms. Anyway, on LE systems the least significant byte comes first (in the sense that if you were to reconstruct it from a stream of bytes, the first byte processed would be the lowest byte of the word).

    >> is there a way to use memcpy to copy the bits of say an integer into a certain place in a bitset?

    As a rule of thumb, using memcpy/memset or otherwise messing with bits should never be used on non-simple types (eg: most classes) since it can often corrupt important state information.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by KBriggs View Post
    Fair enough - on a little endian system, the the MSB on the left or the right?
    That depends whether the computer is upside down or not.

    (The question is nonsense)
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  2. Memcpy(); Errors...
    By Shamino in forum C++ Programming
    Replies: 4
    Last Post: 03-24-2006, 11:35 AM
  3. Using bitset class inside another
    By Dhekke in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2005, 06:50 AM
  4. memcpy with 128 bit registers
    By grady in forum Linux Programming
    Replies: 2
    Last Post: 01-19-2004, 06:25 AM
  5. memcpy
    By doubleanti in forum C++ Programming
    Replies: 10
    Last Post: 02-28-2002, 04:44 PM