Working with bits

John Van Ostrand john at vanostrand.com
Tue Jun 10 11:26:05 PDT 2014


Hi All,

Most of the configuration for the Cochran is stored in bits and I'm
wondering how experience programmers would handle this. Here's a sense of
the data:

short int a5 consists of
   byte 0 : alarm clock minute
   byte 1, bit 7: alarm clock on
   byte 1, bits 6-0: alarm clock hour

There are also 3 and 4 bit integers stored in bytes.

Finally there are decimals stored as
   byte 0: decimal fraction * 256
   byte 1: integer portion

I can create a function that extracts the bits into handy to use values and
another to insert the bits back in. I can also use a struct with bit
positions.

What would you suggest is the best and portable way to handle this?

Thanks
-- 
John Van Ostrand
At large on sabbatical
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libdivecomputer.org/pipermail/devel/attachments/20140610/57e6371a/attachment.html>


More information about the devel mailing list