Date: Mon, 6 Apr 1998 14:47:25 +0300 (IDT) From: Eli Zaretskii To: Spider cc: djgpp AT delorie DOT com Subject: Re: poor fp precision In-Reply-To: <35289C54.7FED@hotmail.com.no.spam> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Transfer-Encoding: 8bit Precedence: bulk On Mon, 6 Apr 1998, Spider wrote: > 2.390000 238.999987 > ^^^^^^^^^^ > Isnīt this very poor????? I mean, if floats have a 6 decimals precision, > one would expect an error less than exp(-6), right?? Wrong. A float has 6 (actually, 6.5) *significant* digits. That is, the 3 digits before the decimal and 3 digits after it, in your case. Anything after that is more than a float can handle. Use double if you have some *real* floating point math to do. > no fp emulation (I use a i486DX2)!!! Is fp calculation that bad with > djgpp? It's not bad, it's what IEEE standard requires. > Doesn't it implement arithmetics with a (double) cast? You are mixing the arithmetics with the way fp variables are *stored*. x87 FPUs do their arithmetics in 10-byte (80-bit) quantities. But when those values are stored, they lose the extra bits beyond what the 4-byte float can hold. If you want all the precision you can get, declare the variables "long double" (that's 80-bit-wide). But just "double" (64 bit) is usually enough.