From 81df1a138416d3ae5b874456ca835e67229ba9a0 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Thu, 8 Feb 2024 20:11:53 +0100 Subject: [PATCH] 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