delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/08/12/08:17:36

From: Kbwms AT aol DOT com
Message-ID: <46.3c4de930.2c6a2e90@aol.com>
Date: Tue, 12 Aug 2003 07:50:40 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_46.3c4de930.2c6a2e90_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

In a message dated 8/12/2003 3:17:57 AM Eastern Standard Time, 
eliz AT elta DOT co DOT il writes:

> Deduction, perhaps mistaken: after the first iteration thru this
> loop:
> 
>    for (; integer &&p >= startp; ++expcnt)
>    {
>   tmp = modfl(integer * 0.1L , &integer);
>   *p-- = tochar((int)((tmp + .01L) * 10));
>    }
> 
> the value of `integer' had a .375 as its fraction.
> 

A mistake is in multiplying by 0.1 instead of dividing by 10 and taking the 
remainder.

--part1_46.3c4de930.2c6a2e90_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/12/2003 3:17:57 AM 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">Deduction, perhaps mistaken: after the first iteration thru=
 this<BR>
loop:<BR>
<BR>
&nbsp;&nbsp; for (; integer &amp;&amp;p &gt;=3D startp; ++expcnt)<BR>
&nbsp;&nbsp; {<BR>
&nbsp; tmp =3D modfl(integer * 0.1L , &amp;integer);<BR>
&nbsp; *p-- =3D tochar((int)((tmp + .01L) * 10));<BR>
&nbsp;&nbsp; }<BR>
<BR>
the value of `integer' had a .375 as its fraction.<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>
A mistake is in multiplying by 0.1 instead of dividing by 10 and taking the=20=
remainder.</FONT></HTML>

--part1_46.3c4de930.2c6a2e90_boundary--

- Raw text -


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