|
Boost : |
Subject: Re: [boost] [gil] Who has a big-endian machine?
From: Belcourt, Kenneth (kbelco_at_[hidden])
Date: 2010-09-03 14:54:37
On Sep 3, 2010, at 12:31 PM, Christian Henning wrote:
> Hi Kenneth,
DBA (doing business as) Noel.
>> 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.
>
> When reading a 3bit tiff image for instance I would have a byte array
> and need to pick off 3bit unsigned integers. There was a bug in gil
> that I have fixed. I also would like to add some test code to make
> sure we can detect problems earlier. But that test code needs to run
> on big and little endian machines.
>
>>
>> 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
>
> Seems like bytes are read left to right on big endian machines.
Yes.
> Could you do me a favor and run again the code below.
Here's the bit pattern (0xDB,0x6D,0xB6). In decimal it's (219,109,182).
Yes, updated against trunk and recompiled. The code below never
enters the else clause (for big endian) so I modified your code by
hand (the version I ran is attached).
v1 = v2 = v3 = 5
v4 = v5 = v6 = 3
v7 = v8 = 0
-- Noel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk