diff --git a/src/exponent.c b/src/exponent.c index 0904080..7dd4455 100644 --- a/src/exponent.c +++ b/src/exponent.c @@ -64,10 +64,9 @@ unsigned long long fac(int x){ double exponential(double x){ double sum = 0.0; - for(int i = 0; i<=20; i++){ + for(int i = 0; i<=21; i++){ sum += (1.0/fac(i)*(powerD(i,x))); } - return sum; } diff --git a/src/logarithmus.c b/src/logarithmus.c index 9bd265d..b15c069 100644 --- a/src/logarithmus.c +++ b/src/logarithmus.c @@ -4,19 +4,19 @@ #include "logarithmus.h" #include "exponent.h" -double logX(double b, double a){ - if(b == 1.0 || b <= 0.0 || a <= 0.0){ +double logX(double base, double value){ + if(base == 1.0 || base <= 0.0 || value <= 0.0){ return -1.0; } - return(logN(a, 0.00000001)/logN(b, 0.00000001)); + return(logN(value, 0.00000001)/logN(base, 0.00000001)); } -double logDec(double a){ - return logX(10.0, a); +double log10(double value){ + return logX(10.0, value); } -double logBin(double a){ - return logX(2.0, a); +double log2(double value){ + return logX(2.0, value); } double logN(double x, double eps){ diff --git a/src/logarithmus.h b/src/logarithmus.h index 68b011f..e94f407 100644 --- a/src/logarithmus.h +++ b/src/logarithmus.h @@ -3,7 +3,7 @@ double logN(double x, double eps); double logX(double b, double a); -double logDec(double a); -double logBin(double a); +double log10(double a); +double log2(double a); #endif // logarithmus.h \ No newline at end of file diff --git a/test/test_logarithmus.c b/test/test_logarithmus.c index 3faad09..d31283b 100644 --- a/test/test_logarithmus.c +++ b/test/test_logarithmus.c @@ -82,12 +82,12 @@ void test_logarithmic_function_with_decimals(void){ void test_logarithmic_function_to_base_10(void){ double r1, r2, r3, r4, r5, r6; - r1 = logDec(100.0); - r2 = logDec(100.6479); - r3 = logDec(10.587); - r4 = logDec(4.341); - r5 = logDec(0.34979); - r6 = logDec(1.0); + r1 = log10(100.0); + r2 = log10(100.6479); + r3 = log10(10.587); + r4 = log10(4.341); + r5 = log10(0.34979); + r6 = log10(1.0); TEST_ASSERT_DOUBLE_WITHIN(0.000001, 2.0, r1); TEST_ASSERT_DOUBLE_WITHIN(0.000001, 2.002804, r2); @@ -100,12 +100,12 @@ void test_logarithmic_function_to_base_10(void){ void test_logarithmic_function_to_base_2(void){ double r1, r2, r3, r4, r5, r6; - r1 = logBin(1024.0); - r2 = logBin(1024.8742); - r3 = logBin(900.587); - r4 = logBin(78.341); - r5 = logBin(0.34979); - r6 = logBin(1.0); + r1 = log2(1024.0); + r2 = log2(1024.8742); + r3 = log2(900.587); + r4 = log2(78.341); + r5 = log2(0.34979); + r6 = log2(1.0); TEST_ASSERT_DOUBLE_WITHIN(0.000001, 10.0, r1); TEST_ASSERT_DOUBLE_WITHIN(0.000001, 10.001231, r2);