[Cfp-interest 1696] Re: printf with %a

Paul Zimmermann Paul.Zimmermann at inria.fr
Fri Jul 17 21:53:27 PDT 2020


> > On Jul 17, 2020, at 8:57 AM, Fred J. Tydeman <tydeman at tybor.com> wrote:
> > 
> > Is
> > printf("%-+#.0La", 3.0L);
> > allowed to output  "+0x2.p+1"
> > instead of "+0x3.p+1"
> > for IEEE-754 binary floating-point?

with gcc 9.3.0 I get +0xc.p-2. Source file is:

#include <stdio.h>
int main()
{
  printf("%-+#.0La\n", 3.0L);
}

I would say indeed it should be corrected rounded according to C 7.21.6.1#11,
thus you cannot get +0x2.p+1.

Paul Zimmermann


More information about the Cfp-interest mailing list