Is there a printf width specifier which can be applied to a floating point specifier that would automatically format the output to the necessary number of s
If you are only interested in the bit (resp hex pattern) you could use the %a format. This guarantees you:
The default precision suffices for an exact representation of the value if an exact representation in base 2 exists and otherwise is sufficiently large to distinguish values of type double.
I'd have to add that this is only available since C99.