WPILibC++ 2023.4.3-108-ge5452e3
sgn.hpp File Reference

Go to the source code of this file.

Functions

template<typename T >
constexpr int sgn (const T x) noexcept
 Compile-time sign function. More...
 

Function Documentation

◆ sgn()

template<typename T >
constexpr int sgn ( const T  x)
constexprnoexcept

Compile-time sign function.

Parameters
xa real-valued input
Returns
a value \( y \) such that

\[ y = \begin{cases} 1 \ &\text{ if } x > 0 \\ 0 \ &\text{ if } x = 0 \\ -1 \ &\text{ if } x < 0 \end{cases} \]