Why .Net and Excel do not agree with this math?

I have very strange behavior from some C # and Excel ...

Having done the math on my own, I believe that excel can give the correct answer, but my math does not really matter, so it may be that the .NET compiler does not know something that I am not doing.

So let's go ...

Given this data as an excel sheet:

total     sale val  days    irr
2431.65   2424.56   21      5.01

The formula for irr (cell D2) is as follows:

=ROUND(100 * ((A2 - B2) / B2) * (360 / C2), 2)

When I run this C #, I get the result 4.97 ...

var totalIncludingTax = 2431.65M;
var saleValue = 2424.56M;
var daysRemaining = 21;

var result = Math.Round(100.0m * ((totalIncludingTax - saleValue) / saleValue) * (360 / daysRemaining), 2);

Can someone explain how I can get C # /. Net and Excel to agree / how can I rewrite this formula so that they agree?

+4
source share
1 answer
360 / daysRemaining

#: 360/21 = 17, 17.14285714, Excel.

360.0 /daysRemaining, ( 360 , ).

+8

Source: https://habr.com/ru/post/1626853/


All Articles