delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/08/11/15:41:07

From: Kbwms AT aol DOT com
Message-ID: <1cd.f004ee0.2c694063@aol.com>
Date: Mon, 11 Aug 2003 14:54:27 EDT
Subject: Re: Anomaly in printf()
To: djgpp-workers AT delorie DOT com
MIME-Version: 1.0
X-Mailer: 8.0 for Windows sub 6011
Reply-To: djgpp-workers AT delorie DOT com

--part1_1cd.f004ee0.2c694063_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

In a message dated 8/11/2003 2:12:53 PM Eastern Standard Time, 
eliz AT elta DOT co DOT il writes:

>  . The closest long double to (unsigned long long)(-1) is
>   18446744073709551613.75;
> 
> 

But, (unsigned long long)(-1) prints out correctly based on my original demo 
program:

#include <stdio.h>

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);
}

--part1_1cd.f004ee0.2c694063_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<HTML><FONT FACE=3Darial,helvetica><FONT  SIZE=3D3 FAMILY=3D"SERIF" FACE=3D"=
Georgia" LANG=3D"0">In a message dated 8/11/2003 2:12:53 PM Eastern Standard=
 Time, eliz AT elta DOT co DOT il writes:<BR>
<BR>
<BLOCKQUOTE TYPE=3DCITE style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT=
: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"></FONT><FONT  COLOR=3D"#000000"=
 style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2 FAMILY=3D"SANSSERIF" FACE=3D"A=
rial" LANG=3D"0"> . The closest long double to (unsigned long long)(-1) is<B=
R>
&nbsp; 18446744073709551613.75;<BR>
<BR>
</BLOCKQUOTE><BR>
</FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D3=
 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><BR>
But, (unsigned long long)(-1) prints out correctly based on my original demo=
 program:<BR>
<BR>
</FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2=
 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0">#include &lt;stdio.h&gt;<BR>
<BR>
int<BR>
main(void)<BR>
{<BR>
&nbsp;&nbsp;&nbsp; long double Demo =3D (unsigned long long)(-1);<BR>
<BR>
&nbsp;&nbsp;&nbsp; printf("Demo&nbsp;&nbsp;&nbsp;&nbsp; =3D %.3Lf\n", Demo);=
<BR>
&nbsp;&nbsp;&nbsp; printf("Demo - 1 =3D %.3Lf\n", Demo-1.0L);<BR>
&nbsp;&nbsp;&nbsp; exit(0);<BR>
}<BR>
</FONT></HTML>
--part1_1cd.f004ee0.2c694063_boundary--

- Raw text -


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