Date: Tue, 29 Apr 1997 19:14:21 +0300 (IDT) From: Eli Zaretskii To: fighteer AT cs DOT com cc: djgpp AT delorie DOT com, David Jenkins Subject: Re: Floating point bug??? In-Reply-To: <336480C1.37C2@SPAMcs.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Mon, 28 Apr 1997, John M. Aldrich wrote: > Your problem is the cumulative error introduced by the lack of precision > of floating point variables. That is correct. > There's no easy way around the problem, because it even persists when > you change the precision of current to double or long double. It's the > repetitive additions and subtractions that cause the problem That is also correct, and the usual way to work around the accumulation of round-off errors is to multiply instead of adding. That is, instead of adding current += SPEED, say something like "current = SPEED * count" where `count' is an integer variable that counts the number of iterations through the loop.