From 6c33f586e6b52fc0394774c78171fa4b6985ee48 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Fri, 9 Feb 2024 16:24:43 +0100 Subject: [PATCH] refactoring: implemented descriptions for methods in arithmetic addition --- src/arithmeticAddition.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arithmeticAddition.c b/src/arithmeticAddition.c index 173c438..46a2e37 100644 --- a/src/arithmeticAddition.c +++ b/src/arithmeticAddition.c @@ -3,6 +3,7 @@ #include #include +// addition for two integer inputs (no decimal number) int* addition_integer(int num1, int num2) { if ((num2 > 0 && num1 > INT_MAX - num2) || (num2 < 0 && num1 < INT_MIN - num2)) { return NULL; @@ -12,18 +13,21 @@ int* addition_integer(int num1, int num2) { return result; } +// addition for two double inputs (decimal number) double* addition_double(double num1, double num2) { double* result = malloc(sizeof(double)); *result = num1+num2; return result; } +// addition for two float inputs (decimal number) float* addition_float(float num1, float num2) { float* result = malloc(sizeof(float)); *result = num1+num2; return result; } +// addition for two long inputs (no decimal number) long* addition_long(long num1, long num2) { long* result = malloc(sizeof(long)); *result = num1+num2;