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

2myIs.png "alt =" Enter the image details here ">

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 Math. PI can be fully displayed in the form of decimals.)

more specifically ..

If you want a round result then & gt; 89.9999 & amp; Amp; & Lt; 9 0.00,001 . Do not use == with floating point value.

Do not use == 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); }  

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.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -