From: Kbwms AT aol DOT com Message-ID: <1e0.eca6e87.2c67e363@aol.com> Date: Sun, 10 Aug 2003 14:05:23 EDT Subject: Re: Anomaly in printf() To: djgpp-workers AT delorie DOT com MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="part1_1e0.eca6e87.2c67e363_boundary" X-Mailer: 8.0 for Windows sub 6011 Reply-To: djgpp-workers AT delorie DOT com --part1_1e0.eca6e87.2c67e363_boundary Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit In a message dated 8/10/2003 1:50:20 PM Eastern Standard Time, dj AT delorie DOT com writes: > >produces the following (erroneous second line of) output: > > > >Demo = 18446744073709551615 > >Demo - 1 = 18446744073709551613 > > > > > >Is this a known problem? > > I've not heard of it. What happens when you use .3 instead of .0 in > that format spec? > Behold: #include int main(void) { long double Demo = (unsigned long long)(-1); printf("Demo = %.3Lf\n", Demo); printf("Demo - 1 = %.3Lf\n", Demo-1.0L); exit(0); } Demo = 18446744073709551615.000 Demo - 1 = 18446744073709551613.000 --part1_1e0.eca6e87.2c67e363_boundary Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable In a message dated 8/10/2003 1:50:20 PM Eastern Standard= Time, dj AT delorie DOT com writes:

>produces the following (erroneous second line of) outpu= t:
>
>Demo    =3D 18446744073709551615
>Demo - 1 =3D 18446744073709551613
>
>
>Is this a known problem?

I've not heard of it.  What happens when you use .3 instead of .0 in that format spec?

Behold:

#include <stdio.h>
int
main(void)
{
    long double Demo =3D (unsigned long long)(-1);

    printf("Demo       =3D %.3L= f\n", Demo);
    printf("Demo - 1 =3D %.3Lf\n", Demo-1.0L);
    exit(0);
}
Demo       =3D 18446744073709551615.000
Demo - 1 =3D 18446744073709551613.000
--part1_1e0.eca6e87.2c67e363_boundary--