|
Libft
Custom implementation of core libc functions with additional utility helpers.
|
Mathematical utilities. More...
Functions | |
| long | min (long a, long b) |
| Returns the minimum of two long integers. | |
| long | max (long a, long b) |
| Returns the maximum of two long integers. | |
| size_t | absolute (long nbr) |
| Returns the absolute value of a long integer. | |
| long | power (int a, int b) |
| Computes a raised to the power of b. | |
| size_t | modulo (long a, size_t b) |
| Computes the modulo of a signed integer with an unsigned modulus. | |
| int | square_root_exact (int nb) |
| Calculates the exact integer square root. | |
| int | square_root_rounded (int nb) |
| Calculates the nearest integer square root. | |
Mathematical utilities.
Functions for common mathematical operations.
| size_t absolute | ( | long | nbr | ) |
Returns the absolute value of a long integer.
| nbr | Number to get absolute value of. |
| long max | ( | long | a, |
| long | b ) |
Returns the maximum of two long integers.
| a | First long integer. |
| b | Second long integer. |
| long min | ( | long | a, |
| long | b ) |
Returns the minimum of two long integers.
| a | First long integer. |
| b | Second long integer. |
| size_t modulo | ( | long | a, |
| size_t | b ) |
Computes the modulo of a signed integer with an unsigned modulus.
Handles negative values of a by ensuring the result is always positive.
| a | Dividend (can be negative). |
| b | Divisor (must be > 0). |
| long power | ( | int | a, |
| int | b ) |
Computes a raised to the power of b.
Uses bit shifting optimization when a == 2.
| a | Base value. |
| b | Exponent (must be >= 0 for meaningful result). |
| int square_root_exact | ( | int | nb | ) |
Calculates the exact integer square root.
| nb | Number to find square root of. |
| int square_root_rounded | ( | int | nb | ) |
Calculates the nearest integer square root.
| nb | Number to find square root of. |