2023-06-25 15:14:06 +02:00
|
|
|
#ifndef __LIBCPROJECT_MATHEMATICS__
|
|
|
|
#define __LIBCPROJECT_MATHEMATICS__
|
2023-01-05 19:28:05 +01:00
|
|
|
|
|
|
|
#define MATHEMATICS_FLOAT_PRECISION 0.00000001
|
|
|
|
|
2023-08-07 00:11:07 +02:00
|
|
|
#include <errno.h>
|
2023-01-05 19:28:05 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2023-06-25 15:07:34 +02:00
|
|
|
#include "types.h"
|
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Verify that 2 numbers are equal.
|
|
|
|
*
|
|
|
|
* @param number1
|
|
|
|
* @param number2
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return true
|
|
|
|
* @return false
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2023-01-05 21:13:10 +01:00
|
|
|
bool mathematics_equals(const float number1, const float number2);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Get the absolute value of a number.
|
|
|
|
*
|
|
|
|
* @param number
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return unsigned long long
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2023-01-05 19:28:05 +01:00
|
|
|
unsigned long long mathematics_absolute_value(const long long number);
|
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Calculates the power of a number.
|
|
|
|
*
|
|
|
|
* @param base
|
|
|
|
* @param exponent
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return unsigned long long
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2023-01-05 19:28:05 +01:00
|
|
|
unsigned long long mathematics_pow(unsigned long long base, unsigned long long exponent);
|
|
|
|
|
|
|
|
/**
|
2023-08-09 21:08:15 +02:00
|
|
|
* @brief Calculates the nth root of a number.
|
2023-01-05 19:28:05 +01:00
|
|
|
*
|
|
|
|
* @param number
|
|
|
|
* @param nth_root
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return float
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
2023-01-05 19:28:05 +01:00
|
|
|
*/
|
|
|
|
float mathematics_root(float number, unsigned int nth_root);
|
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Calculates the square root of a number using Heron's method.
|
|
|
|
*
|
|
|
|
* @param number
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return float
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2023-01-05 19:28:05 +01:00
|
|
|
float mathematics_square_root(float number);
|
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Calculates the factorial of a number.
|
|
|
|
*
|
|
|
|
* @param number
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return unsigned long long
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2023-01-05 19:28:05 +01:00
|
|
|
unsigned long long mathematics_factorial(unsigned long long number);
|
|
|
|
|
|
|
|
#endif
|