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

◆ Fxp() [3/4]

SRL::Math::Types::Fxp::Fxp ( const int16_t & value)
inlineconstexpr

Constructor for Fxp class from a 16-bit signed integer.

Parameters
valueThe integer value to convert to fixed-point.

This is the primary runtime constructor for integer values. For runtime conversion from other numeric types, use Convert():

// Convert with compile-time range validation
Fxp a = Fxp::Convert(someValue); // Warns at compile-time if 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
Note
Converts to 16.16 fixed-point format (e.g., 10 becomes 10.0).
Warning
For advanced users who understand the risks of precision loss or overflow, manual casting is allowed. However, use the Convert function for safer conversions.
// Manual casting (advanced users only)
Fxp b = static_cast<int32_t>(someValue << 16); // No warnings, but risks overflow