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 Content-Type: multipart/alternative; boundary="part1_46.3c4de930.2c6a2e90_boundary" 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 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 >=3D startp; ++expcnt)
   {
  tmp =3D modfl(integer * 0.1L , &integer);
  *p-- =3D 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=20= remainder.
--part1_46.3c4de930.2c6a2e90_boundary--