[FRPythoneers] 24 bit number

Rob Riggs rob at pangalactic.org
Mon Feb 3 13:50:31 MST 2003


You will also want to make sure that the sign bit is extended (as 
needed) and that the byte ordering is correct.  If byte ordering is 
incorrect (and if you are running on an ia32 or other little-endian 
platform), you can use socket.ntohl() to reorder the bytes.



John M. Purser wrote:

>Jorge,
>
>I hadn't even thought about bit shifing.
>
>I'll have to hit the books a bit before following your code but I really
>appreciate the fresh approach!
>
>John Purser
>
>-----Original Message-----
>From: frpythoneers-admin at lists.community.tummy.com
>[mailto:frpythoneers-admin at lists.community.tummy.com]On Behalf Of Jorge
>Seidel
>Sent: Monday, February 03, 2003 11:56 AM
>To: frpythoneers at lists.community.tummy.com
>Subject: Re: [FRPythoneers] 24 bit number
>
>
>John
>
>You might try reading them in as three 32-bit integers and assigning them to
>a Long as a 96 bit integer.  Then use a bit mask to pull out the four 24-bit
>integers from that field.  That would probably be easier than some other
>solutions since the 96 bits aligns with both the 24 and 32 bit integer
>fields.  I haven't tried this (I don't have any 24-bit data fields).
>  
>





More information about the FRPythoneers mailing list