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

◆ Sqrt()

template<Precision P = Precision::Default>
Fxp SRL::Math::Types::Fxp::Sqrt ( ) const
inlineconstexpr

Calculate square root with configurable precision.

Template Parameters
PPrecision level for calculation
Returns
Square root with specified precision

Provides two precision levels with different performance and accuracy trade-offs:

  • Standard: Full precision calculation using the digit-by-digit algorithm
  • Fast: Approximation with varying error rates: • Maximum error of ~42% observed at very small values (~0.000046) • Error decreases as values increase, with most values below 0.0015 having errors between 6-20% • For values above 0.0015, maximum error stabilizes around 6.3%

Choose the appropriate precision based on your requirements:

  • Standard: Use for critical calculations where accuracy is essential
  • Fast: Best for non-critical real-time effects where performance is paramount
Note
Turbo precision mode defaults to Fast for this function.