Message-ID: <3530CED8.1173@pobox.oleane.com> Date: Sun, 12 Apr 1998 16:25:28 +0200 From: Francois Charton Organization: CCMSA MIME-Version: 1.0 To: Eli Zaretskii CC: djgpp AT delorie DOT com Subject: Re: Differences between -lm and not -lm References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Eli Zaretskii wrote: > > On Thu, 9 Apr 1998, Michael Phelps wrote: > > > number %= (int)pow(10, digit_to_start_with); > > number /= (int)pow(10, (digit_to_start_with - length)); > > Don't forget that 10 doesn't have an exact representation as a > floating-point number. So it is subject to round-off errors. Not quite. 10, as all integers, *has* an exact floating point representation (and all basic, +,-,*,/, integer calculations are correctly done in floats). However, pow() (or at least libc pow()) uses log2(10) to make its calculations, and log2(10) has no exact representation as a floating point number... Regards, Francois