summaryrefslogtreecommitdiffstats
path: root/bullet_loan.c
diff options
context:
space:
mode:
authorgonzo <gonzo@toniatuh.com>2023-05-19 22:28:10 +0200
committergonzo <gonzo@toniatuh.com>2023-05-19 22:28:10 +0200
commit2c380f8df666fcebd979511f33e7d72291b389cd (patch)
tree0238209fa73cfa7e4c0a8a58b3ffd8426c20db60 /bullet_loan.c
parent0751b55f611b889f63dfc2bc2705e7537703cb43 (diff)
downloadloan_calc-2c380f8df666fcebd979511f33e7d72291b389cd.tar.gz
moved from floats to doubles for added precision
Diffstat (limited to 'bullet_loan.c')
-rw-r--r--bullet_loan.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/bullet_loan.c b/bullet_loan.c
index 2fc73d6..8ec4be6 100644
--- a/bullet_loan.c
+++ b/bullet_loan.c
@@ -1,6 +1,6 @@
#include "loans.h"
-contract *bullet_init(int n, int d, float r, float P) {
+contract *bullet_init(int n, int d, double r, double P) {
if ((n < 0)) return NULL;
if ((d >= n)||(d < 0)) return NULL;
contract *c = (contract *)calloc(1, sizeof(contract));
@@ -12,16 +12,16 @@ contract *bullet_init(int n, int d, float r, float P) {
return c;
}
-float bullet_update(contract *c) {
+double bullet_update(contract *c) {
if (c->k > c->n)
- return 0.0f;
+ return 0.0;
c->k++;
c->I = c->r * c->P;
if (c->k == c->n) {
c->D = c->P;
- c->P = 0.0f;
+ c->P = 0.0;
}
if (c->k <= c->d) c->P += c->I;