View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
[email protected] alanglloyd@aol.com is offline
external usenet poster
 
Posts: 38
Default Cosine of 90 degrees

On Sep 14, 8:21�pm, "JoeU2004" wrote:
"mikelee101" <mikelee101athotmaildotcom wrote:
I was just curious why I wasn't getting zero for the result of the
cosine of a 90 degree angle. �This formula
=COS(RADIANS(90))


I understand your expectation. �Even though binary arithmetic often causes
subtle differences in results (e.g. IF(10.1-10=0.1,TRUE) returns FALSE!),
many implementations of transcendental and other math functions that are
implemented with approximating formulas make special cases for recognizable
boundary conditions.

For example, that is probably why COS(PI()) is exactly -1.

Since RADIANS(90) returns exactly the same binary result as PI()/2, and
PI()/2 is exactly the binary representation of PI() divided by 2, there is
no reason why the COS() implementation cannot make a special case of
COS(RADIANS(90)) and return exactly zero.

But that's a judgment call. �Obviously, the implementors have to draw a line
somewhere.


In fact bits 11 & 12 of the 8087 (Maths Processor) Control Word has a
setting for that . . .

Bits 11 & 12 of 8987 Control Word
RC- rounding control
00 = round to nearest or even
01 = round towards -infinity
10 = round towards +infinity
11 = truncate towards zero

.. . . and that is easily set & reset in software. The COS() function
should really have implemented that. Possibly on an MS "To Do" list
which has been forgotten <g.

Alan Lloyd