documentation/kernel/utils/math.h.md

36 lines
1.0 KiB
Markdown
Raw Normal View History

2023-05-28 17:16:43 +00:00
# math.h
Mathematical functions, definitions, etc.
# `MAX(a, b)` - macro
Returns the bigger one of the given values.
# `MIN(a, b)` - macro
Returns the smaller one of the given values.
# `CEIL_TO(a, b)` - macro
Aligns **_a_** upwards to **_b_**.
Example: `CEIL_TO(13, 8)` would return 16, because 16 is the next higher multiple of 8 after 13.
# `FLOOR_TO(a, b)` - macro
Aligns **_a_** downwards to **_b_**.
Example: `FLOOR_TO(13, 8)` would return 8, because 8 is the next smaller multiple of 8 before 13.
# `position_T` - struct
This describes a position in 2D space.
| Name | Description |
|------|------------------------------|
| x | X coordinate of the position |
| y | Y coordinate of the position |
# `pow(base, exponent)` - function (uint64_t)
Returns the power of `base ^ exponent`.
# `abs(number)` - function (uint64_t)
Returns the absolute value of **_number_**.
# `octal_string_to_int(string, size)` - function (uint64_t)
Converts a base-8 **_string_** with length **_size_** into an integer and returns it.