Re: HDF5 bitfields...

NOTE: The netcdf-hdf mailing list is no longer active. The list archives are made available for historical reasons.

Hi Ed,
    Bitfields are a black sheep in the datatype family and aren't terribly
well documented (which we're trying to work on).  Say something if you think
we've got a terrible gap about them somewhere.

> Is there an example somewhere about using bitfields in HDF5?
    Hmm, you can look in the test/dtypes.c for some examples of using them.
Search for "H5T_STD_B"...

> Or can you just tell me what functions would be used to create a
> bitfield?
    The H5Tset_precision() routine determines the number of bits in a datatype
that are significant within it.

> Limits on number of bits?
    Up to the size of the datatype that contains it (which is defined for up
to 64-bit datatypes currently).

> How are these stored then? Any sort of padding or what?
    We currently don't pack them, so a 13-bit field in a 32-bit datatype still
takes up 4 bytes of space.  Frankly, I think this is a bit of a bug, but
it's a fairly complicated problem to pack the bits on disk (in light of using
bitfields in compound, array and variable-length datatypes mostly) and noone
has whined strongly about it, so its been the status quo for a while now. :-/


  • 2004 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-hdf archives: