Useful math functions.
More...
|
template<typename T > |
T | Bond::AlignDown (T value, T align) |
| Rounds an integer down to the nearest multiple of a specified power of two. More...
|
|
template<typename T > |
T | Bond::AlignUp (T value, T align) |
| Rounds an integer up to the nearest multiple of a specified power of two. More...
|
|
template<typename T > |
T | Bond::AlignUpDelta (T value, T align) |
| Returns the difference between an integer and the nearest larger multiple of a specified power of two. More...
|
|
template<typename T > |
T * | Bond::AlignPointerDown (T *ptr, size_t align) |
| Rounds a pointer down the nearest multiple of a specified power of two. More...
|
|
template<typename T > |
T * | Bond::AlignPointerUp (T *ptr, size_t align) |
| Rounds a pointer up to the nearest multiple of a specified power of two. More...
|
|
template<typename T > |
T | Bond::IsPowerOfTwo (T value) |
| Returns whether an integer is a power of two. More...
|
|
template<typename T > |
T | Bond::RoundUpToPowerOfTwo32 (T value) |
| Rounds a 32 bit integer up to the nearest power of two. More...
|
|
template<typename T > |
T | Bond::Abs (T value) |
| Returns the absolute value of a number. More...
|
|
template<typename T > |
T | Bond::Min (T a, T b) |
| Compares two numbers and returns the smaller of the two. More...
|
|
template<typename T > |
T | Bond::Max (T a, T b) |
| Compares two numbers and returns the larger of the two. More...
|
|
Useful math functions.
#include "bond/systems/math.h"
◆ Abs()
Returns the absolute value of a number.
- Parameters
-
value | The number whose absolute value is evaluated. |
◆ AlignDown()
template<typename T >
T Bond::AlignDown |
( |
T |
value, |
|
|
T |
align |
|
) |
| |
|
inline |
Rounds an integer down to the nearest multiple of a specified power of two.
- Parameters
-
value | The value to be rounded. |
align | The power of two around which the value is rounded. |
◆ AlignPointerDown()
template<typename T >
T * Bond::AlignPointerDown |
( |
T * |
ptr, |
|
|
size_t |
align |
|
) |
| |
|
inline |
Rounds a pointer down the nearest multiple of a specified power of two.
- Parameters
-
ptr | The pointer to be rounded. |
align | The power of two around which the pointer is rounded. |
◆ AlignPointerUp()
template<typename T >
T * Bond::AlignPointerUp |
( |
T * |
ptr, |
|
|
size_t |
align |
|
) |
| |
|
inline |
Rounds a pointer up to the nearest multiple of a specified power of two.
- Parameters
-
ptr | The pointer to be rounded. |
align | The power of two around which the pointer is rounded. |
◆ AlignUp()
template<typename T >
T Bond::AlignUp |
( |
T |
value, |
|
|
T |
align |
|
) |
| |
|
inline |
Rounds an integer up to the nearest multiple of a specified power of two.
- Parameters
-
value | The value to be rounded. |
align | The power of two around which the value is rounded. |
◆ AlignUpDelta()
template<typename T >
T Bond::AlignUpDelta |
( |
T |
value, |
|
|
T |
align |
|
) |
| |
|
inline |
Returns the difference between an integer and the nearest larger multiple of a specified power of two.
- Parameters
-
value | The value to be rounded. |
align | The power of two around which the value is rounded. |
◆ IsPowerOfTwo()
template<typename T >
T Bond::IsPowerOfTwo |
( |
T |
value | ) |
|
|
inline |
Returns whether an integer is a power of two.
- Parameters
-
◆ Max()
Compares two numbers and returns the larger of the two.
- Parameters
-
a | The first of the two compared numbers. |
b | The second of the two compared numbers. |
◆ Min()
Compares two numbers and returns the smaller of the two.
- Parameters
-
a | The first of the two compared numbers. |
b | The second of the two compared numbers. |
◆ RoundUpToPowerOfTwo32()
template<typename T >
T Bond::RoundUpToPowerOfTwo32 |
( |
T |
value | ) |
|
|
inline |
Rounds a 32 bit integer up to the nearest power of two.
- Parameters
-
value | The value to be rounded. |