I am currently working on a C ++ program where I have a bankAccount class and I need to calculate the percentage. The problem is that my function rounds my numbers to an integer, although I use float as my variable type. Therefore, if I had code like this:
float BankAccount::CalculateInterest(int Time)
{
float thing;
thing = (967 / 365);
return thing;
}
a thing ends with 2.00000000, when it should be 2.649315068.
Any ideas? I used to have my equation of interest, and the result was always 1.00000000, no matter what, so I put it as a test, and I saw that it was rounded to the floor.
Thank you for your help!
source
share