scott-griffiths / bitstring

A Python module to help you manage your bits
https://bitstring.readthedocs.io/en/stable/index.html
MIT License
404 stars 68 forks source link

Allow more types to be pretty printed. #268

Closed scott-griffiths closed 5 months ago

scott-griffiths commented 1 year ago

This is especially useful for the Array type where there is already a fixed interpretation, but needs to be added to the standard pp first.

So as well as 'bin', 'oct', 'hex' and 'bytes' we'd need to add:

'uint' / 'int' : For a width of n bits can easily calculate max characters of integer. 'float8_152' / 'float8_143' / 'bfloat' / 'float16/32/64' : For the 6 types can work out number of characters needed for all significant figures plus 1, plus sign and exponent.

Basically we support the same types as are supported in the Array class, and for each we need to be able to convert from the format type and number of bits to a number of characters needed to print it accurately.

scott-griffiths commented 1 year ago

This should now all work for the Array class, but isn't yet in the other classes, so this becomes a feature request to port the functionality over to those classes.

scott-griffiths commented 5 months ago

Should all be working in 4.2.