This repository has been archived on 2023-09-28. You can view files and clone it, but cannot push or open issues or pull requests.
homepage/content/projects/noxos/docs/codebase/utils/math.h.md

37 lines
1.1 KiB
Markdown
Raw Normal View History

---
title: "math.h"
summary: "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.