Date: Wed, 09 Jun 1999 11:30:16 -0500 From: Eric Rudd Subject: Re: libm sources from cyberoptics To: djgpp-workers AT delorie DOT com Message-id: <375E9698.7D32C155@cyberoptics.com> Organization: CyberOptics MIME-version: 1.0 X-Mailer: Mozilla 4.05 [en] (Win95; U) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit References: Reply-To: djgpp-workers AT delorie DOT com Eli Zaretskii wrote: > Why is the rounding mode important for these functions, but not for > others? Several functions, such as exp, pow, and the hyperbolics, issue the F2XM1 instruction to compute exponential functions. This instruction needs range reduction, which is accomplished by separating the argument into integer and fractional parts. However, the coprocessor instruction to do this (FRNDINT) operates differently, depending on the rounding mode of the coprocessor. The range of approximation for F2XM1 on the newer processors is [-1,+1], which works regardless of the rounding direction, but it may be only [-0.5,+0.5] on some older processors, which would require round-to-nearest. I don't have my old 387 book at my fingertips, so I can't check this at this moment. Several other functions, such as modf, floor and ceil, use FRNDINT directly to produce explicit rounding, but in those functions I change and restore the control word, since round-to-nearest is not what is needed. -Eric Rudd