|
Boost : |
Subject: Re: [boost] [gil] Who has a big-endian machine?
From: Belcourt, Kenneth (kbelco_at_[hidden])
Date: 2010-09-02 17:19:08
On Sep 2, 2010, at 1:34 PM, Christian Henning wrote:
> thanks for sending me the values. I never really dealt with big
> endian. How would the bits are read?
The most significant byte (MSB) is stored at the lowest address.
> For instance, in my test code I
> create this bit pattern:
>
> 1011 0110 0110 1101 1101 1011
>
> On my my little endian system I get 011 for each value, since each
> byte is read right to left. But how is it done with big endian?
Eek, good question.
I'm not quite sure what you're doing but you seem to be picking off
consecutive 3 bit sequences in the buf vector and interpreting them as
integers? For example, the bit_range for p2 references bit_offset 3
into the first byte while p3 references bit 6 in the first byte. And
indeed the value for v2 is 5 which is what I'd expect though v3's
value is 1 rather than 4.
So I'd naively I'd expect the big endian bit sequence above to yield:
101 101 100 110 110 111 011 011
resulting in values for v1 to v8 as:
5 5 4 6 6 7 3 3
So v1 and v2 both seem to be interpreted correctly with the value 5,
but p3 / v3 has clearly gone awry (perhaps due to spanning the byte
boundary).
Not sure if that helps.
-- Noel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk