0

enter image description here

so I am new to C# and I have to write this equation but whatever I do, or however I try to break it down, I tried to just use different double names for some parts of the equation like (1 / 4) is S1 and then the rest as S2 S3 S4 S5 and add an Z1 that merges the whole equation together but I always end up with 0 so i guess the equation is just wrong but i cant see where my mistake is. double c = 10 * (Math.PI / 180); double Z2 = (1 / 4) - ((1 / 4) * Math.Sin(((5 / 2) * (Math.PI)) - (8 * c)));

Kamel Avad
  • 46
  • 7
  • Try to write 1.0 and so in instead and see if it produces the expected result – DownloadPizza Oct 19 '21 at 10:15
  • Does this answer your question? [Divide not returning the decimal value I expect](https://stackoverflow.com/questions/2597029/divide-not-returning-the-decimal-value-i-expect) – Raymond Chen Oct 19 '21 at 10:44

1 Answers1

0

In C#, integer division returns an integer, so 1 / 4 always returns the rounded value of zero. Try division with at least one operand a floating point value, e.g. 1.0 / 4.

polo-language
  • 826
  • 5
  • 13