delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/06/29/06:30:06

From: Waldemar Schultz <schultz AT ma DOT tum DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP reserves wrong int size
Date: Fri, 29 Jun 2001 11:59:59 +0200
Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany)
Lines: 58
Message-ID: <3B3C519F.C542C834@ma.tum.de>
References: <9dde68b7 DOT 0106241053 DOT 2a385311 AT posting DOT google DOT com> <200106242138 DOT RAA18013 AT envy DOT delorie DOT com> <3b37e92e DOT 288745911 AT news DOT primus DOT ca> <200106260242 DOT WAA00615 AT envy DOT delorie DOT com> <3b3b4e40 DOT 213415946 AT news DOT primus DOT ca> <6480-Fri29Jun2001102012+0300-eliz AT is DOT elta DOT co DOT il>
NNTP-Posting-Host: pcritter14.mathematik.tu-muenchen.de
Mime-Version: 1.0
X-Trace: wsc10.lrz-muenchen.de 993808797 23293 131.159.68.151 (29 Jun 2001 09:59:57 GMT)
X-Complaints-To: news AT lrz-muenchen DOT de
NNTP-Posting-Date: 29 Jun 2001 09:59:57 GMT
X-Mailer: Mozilla 4.77 [en] (Win98; U)
X-Accept-Language: de,en-US
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii wrote:
> They work for me, in GCC 2.95.3.  (I didn't use 2.95.2 long enough to
> tell.)
> 
> For long doubles, the right format for debugging printf's is "%.19g".
      ^^^^                                                     "%.19Lg"
right?
> Note: "g", not "f", because you want 19 significant digits, not 19
> digits after the dot (think about a number like 123456789.987654321).
> 
> For the same reason, I suggest to use "%.16g" for doubles.
> 
> > I am somewhat curious as to how printf
> > knows the format of a double or for that matter int you pass it
> > however.
> 
> It doesn't; it simply assumes that the format specifier tells the
> truth.  That is, if you say "%f", the corresponding argument is a
> double, and if you say "%Lf", it's a long double.
so IMHO the libc info pages about printf/scanf are wrong.
(at least for DJGPP + gcc)

scanf():
    `Le'
    `LE'
    `lle'
    `llE'
    `Lf'
    `LF'
    `llf'
    `llF'
    `Lg'
    `LG'
    `llg'
    `llG'
          Convert the input to a `long double'.

printf():
    `e'
    `E'
          A floating point number (double or long double).  The
          exponent case matches the specifier case.  The representation
          always has an exponent.

    `f'
          A floating point number (double or long double).  The
          representation never has an exponent.

    `g'
    `G'
          A floating point number (double or long double).  The
          exponent case matches the specifier case.  The representation
          has an exponent if it needs one.

-- 
 Gruss Waldemar Schultz.         schultz AT ma DOT tum DOT de
 Technische Universität München, Zentrum Mathematik M1, D 80290 München
 Tel: +49 (0)89 2892 8226        FAX: +49 (0)89 2892 8228

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019