public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/97365] New: gcvt and qgcvt do not always provide requested precision
@ 2020-10-11  3:14 sisyphus359 at gmail dot com
  2020-10-12  6:25 ` [Bug c/97365] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: sisyphus359 at gmail dot com @ 2020-10-11  3:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97365

            Bug ID: 97365
           Summary: gcvt and qgcvt do not always provide requested
                    precision
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sisyphus359 at gmail dot com
  Target Milestone: ---

gcvt() will assign no more than 17 digits of precision.
qgcvt() will assign no more than 21 digits of precision.

Here is the demo :

/************************************************/
#include <stdio.h>
#include <stdlib.h>

int main(void) {
 char ebuf[80];

 gcvt(0.1, 55, ebuf);
 printf("%s\n", ebuf);

 qgcvt(0.1L, 67, ebuf);
 printf("%s\n", ebuf);

 return 0;
}

/************************************************/

On Ubuntu-20.04, gcc-9.3.0
I got:
0.10000000000000001
0.100000000000000000001

I expected:
0.1000000000000000055511151231257827021181583404541015625
0.1000000000000000000013552527156068805425093160010874271392822265625

The "expected" values are exact base 10 representations of the values contained
in the double 0.1, and in the (80-bit extended precision) long double 0.1.

Cheers,
Rob

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/97365] gcvt and qgcvt do not always provide requested precision
  2020-10-11  3:14 [Bug c/97365] New: gcvt and qgcvt do not always provide requested precision sisyphus359 at gmail dot com
@ 2020-10-12  6:25 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-12  6:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97365

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
This isn't a problem in the compiler but the used C library.  Please report the
issue there.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-12  6:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-11  3:14 [Bug c/97365] New: gcvt and qgcvt do not always provide requested precision sisyphus359 at gmail dot com
2020-10-12  6:25 ` [Bug c/97365] " rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).