using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YLErp.Helpers
{
public static class CalculateHelper
{
///
/// 计算复利的函数
///
/// 本金
/// 年利率
/// 投资时间(天)
/// 复利总额
public static double CompoundInterest(double principal, double rate, int time,int annualDays=365)
{
double dailyRate = rate / (double)annualDays;
// 计算复利公式中的指数部分
double exponent = dailyRate * time;
// 利用指数函数计算复利总额
double total = principal * Math.Pow(1 + exponent, time / (double)annualDays);
// 计算复利总额(保留两位小数)
return Math.Round(total, 2);
}
}
}