[Cfp-interest 2891] Re: standardize printf %a/%A

Steve (Swift) Canon scanon at apple.com
Tue Sep 5 10:20:26 PDT 2023


> On Sep 4, 2023, at 12:19 PM, Paul Zimmermann <Paul.Zimmermann at inria.fr> wrote:
> 
>       Hi,
> 
> on the MPFR list there was some discussion about printf with hexadecimal
> values (%a/%A):
> 
> https://sympa.inria.fr/sympa/arc/mpfr/2023-09/msg00004.html
> 
> It seems to me there is no convention in the C standard
> (both for normal and subnormal values).
> Would it make sense to have one?

One consideration that makes it difficult to have a sensible default is the mandatory promotion of float (and other small types) to double in varargs functions like the printf family. Unfortunately float and double don’t have the same number of fractional bits mod 4, so many rules that one might want to standardize will not hold when floats are used, leading to a certain amount of surprise for users who don’t understand the promotion rules.

That isn’t to say that it’s not worth doing, but a certain amount of confusion is hard to avoid.

– Steve


More information about the Cfp-interest mailing list