libyggdrasil  v1.0.0
bsp::math Namespace Reference

Functions

template<typename T >
constexpr T clamp (T value, T min, T max)
 Clamps a input value between a min and max value. More...
 
template<typename T >
constexpr T degreeToRadian (T deg)
 Conversion between degree and radian. More...
 
template<typename T >
constexpr T radianToDegree (T rad)
 Conversion between radian and degree. More...
 
constexpr ALWAYS_INLINE u64 operator""_kB (u64 n)
 Kibibyte literal. More...
 
constexpr ALWAYS_INLINE u64 operator""_MB (u64 n)
 Mibibyte literal. More...
 
constexpr ALWAYS_INLINE u64 operator""_GB (u64 n)
 Gibibyte literal. More...
 
template<u16 Polynomial = 0x8005>
constexpr u16 crc16 (const auto &data, u16 initialValue=0x00)
 Calculates the CRC16 Checksum of the data in a container. More...
 
template<u32 Polynomial = 0x04C11DB7>
u32 crc32 (const auto &data, u32 initialValue=0x00)
 Calculates the CRC32 Checksum of the data in a container. More...
 
constexpr ALWAYS_INLINE u8 bcdToBinary (u8 bcd)
 Converts a Binary Coded Decimal value to Binary. More...
 
constexpr ALWAYS_INLINE u8 binaryToBcd (u8 bin)
 Converts a Binary value to Binary Coded Decimal. More...
 

Function Documentation

◆ bcdToBinary()

constexpr ALWAYS_INLINE u8 bsp::math::bcdToBinary ( u8  bcd)
constexpr

Converts a Binary Coded Decimal value to Binary.

Parameters
bcdBCD input
Returns
Binary representation

◆ binaryToBcd()

constexpr ALWAYS_INLINE u8 bsp::math::binaryToBcd ( u8  bin)
constexpr

Converts a Binary value to Binary Coded Decimal.

Parameters
binBinary input
Returns
BCD representation

◆ clamp()

template<typename T >
constexpr T bsp::math::clamp ( value,
min,
max 
)
constexpr

Clamps a input value between a min and max value.

Parameters
valueInput
minMin value
maxMax value
Returns
Clamped value

◆ crc16()

template<u16 Polynomial = 0x8005>
constexpr u16 bsp::math::crc16 ( const auto &  data,
u16  initialValue = 0x00 
)
constexpr

Calculates the CRC16 Checksum of the data in a container.

Note
There is also a hardware CRC module
Template Parameters
PolynomialPolynomial used to calculate LUT
Parameters
dataIterateable Container type
initialValueValue to start at
Returns
CRC16 checksum

◆ crc32()

template<u32 Polynomial = 0x04C11DB7>
u32 bsp::math::crc32 ( const auto &  data,
u32  initialValue = 0x00 
)

Calculates the CRC32 Checksum of the data in a container.

Template Parameters
PolynomialPolynomial used to calculate LUT
Parameters
dataIterateable Container type
initialValueValue to start at
Returns
CRC32 checksum

◆ degreeToRadian()

template<typename T >
constexpr T bsp::math::degreeToRadian ( deg)
constexpr

Conversion between degree and radian.

Parameters
degDegree
Returns
Radians

◆ operator""_GB()

constexpr ALWAYS_INLINE u64 bsp::math::operator""_GB ( u64  n)
constexpr

Gibibyte literal.

◆ operator""_kB()

constexpr ALWAYS_INLINE u64 bsp::math::operator""_kB ( u64  n)
constexpr

Kibibyte literal.

◆ operator""_MB()

constexpr ALWAYS_INLINE u64 bsp::math::operator""_MB ( u64  n)
constexpr

Mibibyte literal.

◆ radianToDegree()

template<typename T >
constexpr T bsp::math::radianToDegree ( rad)
constexpr

Conversion between radian and degree.

Parameters
radRadians
Returns
Degrees