cfloat: Generalize double_format to allow specifying precision.