jDataView has bitfield support for I/O operations on numbers with non-standard bit length. Such numbers are widely used in different popular binary formats, especially in those that are used for data compression or storing multimedia information.
Those methods allow to use
bitLength <= 32 bits. Don't forget to manually ensure byte padding before reading non-bitfield values after calling those methods (if you implement some standard popular format, it's most likely already done for you).
setSigned(byteOffset, value, bitLength)
setUnsigned(byteOffset, value, bitLength)