salman,
I occasionally get results like this. In some cases, these small non zero
results do worry me (as they may generate a negative answer that is input into
some later function such as a log, which will then generate an error). To get
around this, I wrote a small wrapper for the sin and cos functions that
determine if the input value is close to 0 or pi (or a multiple).. The closeness
is dependence upon the desired accuracy. this wrapper will then return the
appropriate 'exact' answer.
Mic
Salman Saeed wrote:
> Im getting weird results at times from both the Sin and Cosine function.
> Sin(0.0) gives me results such as 0.xx E32 and Cos(pi/2) being the same.
> Anyone ever run into this bizzare behavior? This typically happens when i do
> Sin(theta(n)) where theta is an array and one of its elements is 0.0
> Any ideas?
> Salman Saeed
> ssaeed@kent.edu

Michael Crump
Research Engineer / PhD Candidate
Sir Lawrence Wackett Centre for Aerospace Design Technology
Department of Aerospace Engineering
RMIT University
GPO Box 2476V
Melbourne, Vic 3001
AUSTRALIA
Ph: +61 3 9647 3089
Fax: +61 3 9647 3050
