From 85ce5228ef0e2ebaa973b79083f29879051055fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Fri, 13 Sep 2024 14:44:26 +0200 Subject: [PATCH] feat: add `mathematics_opposite` --- lib/mathematics.c | 4 ++++ lib/mathematics.h | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/mathematics.c b/lib/mathematics.c index 32a406b..b8d14d9 100644 --- a/lib/mathematics.c +++ b/lib/mathematics.c @@ -32,3 +32,7 @@ float mathematics_square_root(float number) { unsigned long long mathematics_factorial(unsigned long long number) { return number == 0 ? 1 : number * mathematics_factorial(number - 1); } + +int64_t mathematics_opposite(int64_t number) { + return number * -1; +} diff --git a/lib/mathematics.h b/lib/mathematics.h index 722cd59..c13bcbb 100644 --- a/lib/mathematics.h +++ b/lib/mathematics.h @@ -66,4 +66,12 @@ float mathematics_square_root(float number); */ unsigned long long mathematics_factorial(unsigned long long number); +/** + * @brief Calulcates the opposite number (additive inverse). + * + * @param number + * @return int64_t + */ +int64_t mathematics_opposite(int64_t number); + #endif