www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/27/11:16:46

From: Andrew Gibson <andrew AT petrologic DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: printf 'g' conversion
Date: Fri, 27 Feb 1998 15:17:05 +0000
Message-ID: <34F6D8EE.BF28CC5B@petrologic.co.uk>
NNTP-Posting-Host: petrologic.demon.co.uk
MIME-Version: 1.0
Lines: 31
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I was comparing the output from a program compiled with DJGPP and the
output from the same program compiled with gcc in Linux. The output was
generated from calls to printf with ‘g’ as the conversion character. I
found that for values with absolute value less than 0.1 the outputs
differed.

For example the call:      printf(“%9.9g”,0.0123456789);
displays

0.012345679

using DJGPP but

0.0123456789

using Linux.

The definition for the ‘g’ conversion character says the ‘.n’ modifier
means that at most n significant figures are printed. I think this means
in the example above the .9 means I’m asking for 9 significant figures.
From Linux this is what I get. From DJGPP I get 9 decimal places and
only 8 sig figs.

I have modified my DJGPP library source to make it work the same as
Linux in this case.

Does anyone have any comments?

Andrew Gibson
 

- Raw text -


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