c# - Why does Math.Tan(90) provide a non-undefined value? -
While working with Math.Tan ()
I found that 90 degrees is not the result is . But
Here is the code,
// change in angle angle = (convert. Repeat (op1) * Math.PI / 180); // Write Output Final Result. Text = Mutt.Tan (Convert.Dual Angle ()). ToString ();
Why such behavior is done, is it expected?
The calculation is done with the floating point number which is not correct (not that more specifically .. If you want a round result then Do not use We are multiplying 0.2 by a whole number, dividing it by the same whole number, and then comparing 0.2. It should be correct every time, right? this. Many times it gives false returns. Math. PI can be fully displayed in the form of decimals.)
& gt; 89.9999 & amp; Amp; & Lt; 9 0.00,001
. Do not use ==
with floating point value. ==
with floating point number, try running this example:
var d = 0.2 ; For (double k = 1.0; k & lt; 100; k ++) {var t = 0.2 * k; T = T / K; Console.light line ("{0} == {1} ==> {2}", D, T, D == t); }
Comments
Post a Comment