Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Math

Useful math functions. More...

Functions

template<typename T>
Bond::AlignDown (T value, T align)
 Rounds an integer down to the nearest multiple of a specified power of two.
template<typename T>
Bond::AlignUp (T value, T align)
 Rounds an integer up to the nearest multiple of a specified power of two.
template<typename T>
Bond::AlignUpDelta (T value, T align)
 Returns the difference between an integer and the nearest larger multiple of a specified power of two.
template<typename T>
T * Bond::AlignPointerDown (T *ptr, size_t align)
 Rounds a pointer down the nearest multiple of a specified power of two.
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.
template<typename T>
Bond::IsPowerOfTwo (T value)
 Returns whether an integer is a power of two.
template<typename T>
Bond::RoundUpToPowerOfTwo32 (T value)
 Rounds a 32 bit integer up to the nearest power of two.
template<typename T>
Bond::Abs (T value)
 Returns the absolute value of a number.
template<typename T>
Bond::Min (T a, T b)
 Compares two numbers and returns the smaller of the two.
template<typename T>
Bond::Max (T a, T b)
 Compares two numbers and returns the larger of the two.

Detailed Description

Useful math functions.

#include "bond/systems/math.h"

Function Documentation

◆ Abs()

template<typename T>
T Bond::Abs ( T value)
inline

Returns the absolute value of a number.

Parameters
valueThe 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
valueThe value to be rounded.
alignThe 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
ptrThe pointer to be rounded.
alignThe 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
ptrThe pointer to be rounded.
alignThe 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
valueThe value to be rounded.
alignThe 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
valueThe value to be rounded.
alignThe 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
valueThe value to test.

◆ Max()

template<typename T>
T Bond::Max ( T a,
T b )
inline

Compares two numbers and returns the larger of the two.

Parameters
aThe first of the two compared numbers.
bThe second of the two compared numbers.

◆ Min()

template<typename T>
T Bond::Min ( T a,
T b )
inline

Compares two numbers and returns the smaller of the two.

Parameters
aThe first of the two compared numbers.
bThe 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
valueThe value to be rounded.