[edit] this just gets stranger the more I look at it. I'm going to have to change my mind and say I don't know.
---------- Post updated at 10:12 AM ---------- Previous update was at 09:38 AM ----------
Just done some more research here, comparing bitfields on big and little endian machines I have access to, and learned something new. Bitfields reverse direction on big endian platforms. Considering the following code:
On a little-endian platform it prints:
On a big-endian platform it prints:
So yes, it does need to reverse the direction of bits, not just bytes, because the compiler chooses blocks of bits in the reverse direction.
And yet, if we make INVERT subtract two instead of one, we get:
so the blocks of bits are treated in the correct, normal direction, even if the direction they are grouped in is reversed. Weird! But I suspect there is a rational reason -- that being, when a grouping of bits crosses a byte or word boundary, to make sure the two halves split by the boundary are combined in the right order.
So the code as given was correct, strange as it looks.
Last edited by Corona688; 08-27-2009 at 01:18 PM..
You'd probably be better off using a uint32_t, bit-masking out the fields, and making sure you always use hton() to write the data and ntoh() to read it.
They may not work on some embedded platforms, but beyond that, they're fairly portable in the "compiles" sense, though where the bits actually end up depends a lot on your architecture. I'd tend to agree they're more trouble than just using binary logic operations.
Hi team
Optimizer max permutations and search limit are set to 3.5 million and 10 respectively.The parameter instruct optimizer to evaluate up to 3.5 million permutations for max 10 table joins
I have query with 9 tables joined.
How many combinations will optimizer perform to find best... (1 Reply)
Hi
Im migrating a few websites from my old webserver (CentOS-5) to a new server (CentOS6) , one of these websites is multilingual and has a lot of utf8 files(html,php) with different languages (i.e arabic, persian, russian ,etc).
In old server when i do:
file mailer.php
I get :
... (6 Replies)
Hi
I've a pkts trace and I'm performing some test on it. I'd like to figure out also the numbers of total byte in that trace.
Any idea?
thanks in advance
D. (0 Replies)
Hi All
Can anyone please suggest me how to remove the last byte from a falt file .This is from the last line's last BYTE.
Please suggest me something.
Thank's and regards
Vinay (1 Reply)
In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server.
For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match.
Please... (4 Replies)
Please help me in removing the 2nd file :
-rw-rw-rw- 1 fup03a fup03a 9216 Aug 16 00:45 med_delay_log
-rw-rw-rw- 1 fup03a fup03a 0 Aug 16 18:04 (5 Replies)
In one of the Unix Programming FAQ's they have the following headers in the program to catch SIGCHLD
#include <sys/types.h> /* include this before any other sys headers */
#include <sys/wait.h> /* header for waitpid() and various macros */
#include <signal.h> /* header for signal... (5 Replies)
Hi,
Can someone explain what is byte padding?
For ex:
struct emp{
char s;
int b;
char s1;
int b1;
long b3;
char s3;
}
What will be the size of this structure?
Thanks (6 Replies)
My program would be creating a file, incase of non data from database it would only able to produce 'END, logically it would be file created by oracle in unix.
this file is showing zero byte but actully there are 4 char in file.This is not required, therefore what is command line should be... (0 Replies)