From c0b2e43eb81eed70bea188a353946fa00022ba14 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Thu, 8 Feb 2024 20:19:58 +0100 Subject: [PATCH] Expanded arithmetic division with datatype --- src/arithmeticDivision.c | 9 +++++++++ src/arithmeticDivision.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/arithmeticDivision.c b/src/arithmeticDivision.c index 0090bbd..4bb8a58 100644 --- a/src/arithmeticDivision.c +++ b/src/arithmeticDivision.c @@ -32,4 +32,13 @@ double* division_double(double dividend, double divisor) { double* result = malloc(sizeof(double )); *result = dividend / divisor; return result; +} + +float* division_float(float dividend, float divisor) { + if(divisor == 0) { + return NULL; + } + float* result = malloc(sizeof(float)); + *result = dividend / divisor; + return result; } \ No newline at end of file diff --git a/src/arithmeticDivision.h b/src/arithmeticDivision.h index df45e81..9ae1a34 100644 --- a/src/arithmeticDivision.h +++ b/src/arithmeticDivision.h @@ -7,4 +7,6 @@ long* division_long(long, long); double* division_double(double, double); +float* division_float(float, float); + #endif //THEADMIRALS_ARITHMETICDIVISION_H