delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/03/10:43:32

Date: Thu, 03 Feb 2000 09:34:37 -0600
From: Weiqi Gao <weiqi DOT gao AT edwardjones DOT com>
Subject: Re: Gawk 3.0.3 print error?
To: djgpp AT delorie DOT com
Message-id: <3899A00D.1F816639@edwardjones.com>
Organization: Edward Jones
MIME-version: 1.0
X-Mailer: Mozilla 4.51 [en]C-CCK-MCD (WinNT; U)
X-Accept-Language: en
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000203080825 DOT 3341C-100000 AT is>
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii wrote:
> 
> On 2 Feb 2000, Giacomo Cau wrote:
> 
> > > > >gawk "BEGIN{OFMT=\"%012.0f\";print OFMT,1,sprintf(OFMT,1)}"
> > > >
> > > > %012.0f 1 000000000001
> > >
> > > What seems to be the problem, exactly?  I don't see anything wrong
> > > with this result; that's what I'd expect "%012.0f" to produce.
> > > The leading zero > says to pad with zeros, and .0 says no
> > > fractional digits.
> >
> > the problem is not in the "sprintf" but is in the "print 1".
> > In fact it seems that OFMT in not used to format numbers.
> 
> No, OFMT *is* used to format numbers: try 1.1 instead of 1, and you
> will see it.
> 
> It seems like `print' only uses OFMT for floating point numbers, not
> for integers.  I don't know if that's a bug, but I don't think there's
> anything DJGPP-specific in this behavior.  So please post this report
> to gnu.utils.bug, where Gawk maintainer(s) will give you a definitive
> answer.  Please mention there that you are using the DJGPP port, in
> case it's important.

It might not be GNU awk only either, but there is comp.lang.awk.

--
Weiqi Gao
weiqigao AT a DOT crl DOT com

- Raw text -


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