bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bugs in printf/sprintf formatted output


From: Maciej W. Rozycki
Subject: Re: Bugs in printf/sprintf formatted output
Date: Tue, 6 Aug 2024 18:01:27 +0100 (BST)

On Tue, 6 Aug 2024, arnold@skeeve.com wrote:

> > > I see that you found differences in %a between gawk and GLIBC. There too,
> > > gawk just calls into the C library (or MPFR).  If it's an issue of
> > > the default precision or something, perhaps I can make a change, but
> > > you'll need to tell me what's going on.
> >
> >  It's only MPFR implementation that concerns me here, because obviously 
> > verifying glibc against itself makes no sense (and I'd expect output to 
> > match anyway).
> 
> Please clarify. For non-MPFR the results are the same?

 They are.

 Try e.g. { printf "%.13a", -1.79769313486231570814527423731704357e+308 }, 
which prints "-0x1.fffffffffffffp+1023" (glibc implementation) or 
"-0xf.ffffffffffff8p+1020" (MPFR implementation).

 That is aside from the default precision issue in the MPFR mode, where 
e.g.: { printf "%a", -1.79769313486231570814527423731704357e+308 } prints 
"-0x1.000000p+1024" in violation of POSIX, which says:

"if the precision is missing and FLT_RADIX is a power of 2, then the 
precision shall be sufficient for an exact representation of the value"

which obviously has not been met here (i.e. "-0xf.ffffffffffff8p+1020" is 
supposed to be produced as with explicit precision of 13).

 Let me know if you have any other questions.

  Maciej




reply via email to

[Prev in Thread] Current Thread [Next in Thread]