utx::abs calculates an absolute value of a mathematical real value. That is, if the value < 0, return -value, else return value.
Return type is the same as the type of value.
constexpr auto abs_value = utx::abs(value);
Return type is the same as the type of value.
constexpr auto abs_value = utx::abs.fn(value);
Return type is always return_type .
For example,
utx::abs.fn<utx::fx64>(-2.55)
returns 2.55 ;
utx::abs.fn<utx::fx64>(-2)
returns 2.0 ;
constexpr auto abs_value = utx::abs.fn<return_type>(value);
Return type is return_type, arg type is arg_type.
For example,
utx::abs.fn<utx::fx64, utx::i64>(-2.55)
returns 2.0 ;
utx::abs.fn<utx::fx64>(-2)
returns 2.0 ;
constexpr auto abs_value = utx::abs.fn<return_type, arg_type>(value);
arg value => return value:
#include <utxcpp/core.hpp> #include <utxcpp/math.hpp> int main() { for (utx::ix32 i=-4; i<=4; ++i) utx::print(utx::abs(i)); }