From 7077c22833e9719986ee98cb96c71c6ba9115f2f Mon Sep 17 00:00:00 2001 From: Sandro Welte Date: Thu, 8 Feb 2024 20:07:22 +0100 Subject: [PATCH 1/4] refactoring: removed unnecessary description --- src/arithmeticMultiplication_Int.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arithmeticMultiplication_Int.c b/src/arithmeticMultiplication_Int.c index 1ad1a19..6aaea5f 100644 --- a/src/arithmeticMultiplication_Int.c +++ b/src/arithmeticMultiplication_Int.c @@ -6,7 +6,7 @@ int* multiplication_integer(int a, int b) { int *result = (int*)malloc(sizeof(int)); if (result == NULL) { - // Handle memory allocation failure + return NULL; } From ff9a829bfb035d43322fd72d3c6d99e843c58fda Mon Sep 17 00:00:00 2001 From: Sandro Welte Date: Thu, 8 Feb 2024 20:07:52 +0100 Subject: [PATCH 2/4] refactoring: removed unnecessary description --- src/arithmeticMultiplication_Float.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arithmeticMultiplication_Float.c b/src/arithmeticMultiplication_Float.c index 8e063f2..547b9d7 100644 --- a/src/arithmeticMultiplication_Float.c +++ b/src/arithmeticMultiplication_Float.c @@ -4,7 +4,7 @@ float* multiplication_float(float a, float b) { float* result = (float*)malloc(sizeof(float)); if (result == NULL) { - return NULL; // Handle memory allocation failure + return NULL; } *result = a * b; return result; From cf9bc55bc5fb7ac09f8a3e20c94102d90a436a6a Mon Sep 17 00:00:00 2001 From: Sandro Welte Date: Thu, 8 Feb 2024 20:08:11 +0100 Subject: [PATCH 3/4] refactoring: removed unnecessary description --- src/arithmeticMultiplication_Double.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arithmeticMultiplication_Double.c b/src/arithmeticMultiplication_Double.c index 3207551..c33d245 100644 --- a/src/arithmeticMultiplication_Double.c +++ b/src/arithmeticMultiplication_Double.c @@ -5,7 +5,7 @@ double* multiplication_double(double a, double b) { double* result = (double*)malloc(sizeof(double)); if (result == NULL) { - return NULL; // Handle memory allocation failure + return NULL; } *result = a * b; // we multiply a times b and the result gets saved in *result return result; From 81df1a138416d3ae5b874456ca835e67229ba9a0 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Thu, 8 Feb 2024 20:11:53 +0100 Subject: [PATCH 4/4] Implemented division for double values --- src/arithmeticDivision.c | 12 ++++++++++++ src/arithmeticDivision.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/arithmeticDivision.c b/src/arithmeticDivision.c index dfdf00a..3233c7b 100644 --- a/src/arithmeticDivision.c +++ b/src/arithmeticDivision.c @@ -23,4 +23,16 @@ long* division_long(long dividend, long divisor) { long* result = malloc(sizeof(long)); *result = dividend / divisor; return result; +} + +double* division_double(double num1, double num2) { + if(num2 == 0) { + return NULL; + } + + + + double* result = malloc(sizeof(double )); + *result = num1 / num2; + return result; } \ No newline at end of file diff --git a/src/arithmeticDivision.h b/src/arithmeticDivision.h index 08bc4f5..df45e81 100644 --- a/src/arithmeticDivision.h +++ b/src/arithmeticDivision.h @@ -5,4 +5,6 @@ int* division_integer(int, int); long* division_long(long, long); +double* division_double(double, double); + #endif //THEADMIRALS_ARITHMETICDIVISION_H