SaturnRingLibrary 0.9.1
SGL wrapper
 
Loading...
Searching...
No Matches

◆ Convert() [1/2]

template<std::integral T>
static constexpr Fxp SRL::Math::Types::Fxp::Convert ( const T & value)
inlinestaticconstexpr

Convert integral type to fixed-point with compile-time range validation.

Template Parameters
TIntegral type (e.g., int, int32_t)
Parameters
valueThe value to convert
Returns
Fixed-point value

Converts an integral value to 16.16 fixed-point format with compile-time validation. Using int16_t{value} ensures the value fits within the valid range (-32768 to 32767). The compiler will warn if the value is outside this range.

This is a RUNTIME conversion method. For compile-time conversion, prefer using the Fxp constructor directly with constexpr when possible.

Example:

auto a = Fxp::Convert(5); // OK: 5 fits in int16_t
auto b = Fxp::Convert(50000); // Warning: value exceeds int16_t range
static constexpr Fxp Convert(const T &value)
Convert integral type to fixed-point with compile-time range validation.
Definition fxp.hpp:156