Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: tangent
|
Posted: Apr 1, 2003 8:26 AM
|
|
I don't think it is a problem. Because pi is an irrational number, you cannot represent it exactly, therefore it is impossible to hit on the exact spot where the tangent would be infinite. Anyway, if you manage to find a value that is close enough, Math.Tan() will just return NaN instead of crashing the system, as in the old days with "divide by zero error."
If you want to avoid the possibility of even getting NaN, then it is also quite simple to calculate (you already know how) that the tangent will be infinite based on what value the user entered and inform the user without ever calling Tan(). If the values from the user are progressing in one way or the other, you can also tell the user whether it is negative or positive infinity.
|
|