0

If I run this simple calculation in C# the value is completely different than Excel or Win calculator.

var result = (300 / 250 * 4.3M * 25);

In c# the result is 107.5

In Excel and Windows Calculator the result is 129

What am I doing wrong?

user2818430
  • 5,853
  • 21
  • 82
  • 148

1 Answers1

1

When you divide 300 with 250 - you divide 2 integers - so the results is 1 and not what you may expected - 1.2

When you do that in calculator the values are floating numbers and the results is 1.2 as expected

129 / 107 = 1.2

Igal S.
  • 13,146
  • 5
  • 30
  • 48