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