-3

Here's my code:

public static class Angle
{
    public static double DegreesToGradians(double degrees)
    {
        return degrees * (200 / 180);
    }
}

The problem is, let's say degrees = 1, 1 * (200 / 180) should be 1.11111d, but for some reason I keep getting 1.0d, why would it be auto rounding and how do I stop that?

eglease
  • 2,445
  • 11
  • 18
  • 28
  • try `200.0 / 180.0`, Right now, 200 and 100 are integers and are divided like integers with no remainder. – eglease Aug 17 '23 at 17:30
  • 2
    `should be 1.11111d` no, it's not, because `200 / 180` is integer division, not floating point – Renat Aug 17 '23 at 17:30
  • 1
    Thank you everyone, not sure how to mark this as answered now but adding decimals in the formula did the trick. – SgtLundy Aug 17 '23 at 17:35

0 Answers0