24 #ifndef ARM_COMPUTE_UTILS_ROUNDING_H
25 #define ARM_COMPUTE_UTILS_ROUNDING_H
61 template <
typename T, ARM_COMPUTE_REQUIRES_TA(traits::is_
floating_po
int<T>::value)>
64 T res = std::floor(std::fabs(value));
65 return (value < 0.f) ? -res : res;
76 template <
typename T, ARM_COMPUTE_REQUIRES_TA(traits::is_
floating_po
int<T>::value)>
79 T res = std::ceil(std::fabs(value));
80 return (value < 0.f) ? -res : res;
91 template <
typename T, ARM_COMPUTE_REQUIRES_TA(traits::is_
floating_po
int<T>::value)>
94 T res = T(std::ceil(std::fabs(value) - 0.5f));
95 return (value < 0.f) ? -res : res;
106 template <
typename T, ARM_COMPUTE_REQUIRES_TA(traits::is_
floating_po
int<T>::value)>
109 T res = T(std::floor(std::fabs(value) + 0.5f));
110 return (value < 0.f) ? -res : res;
121 template <
typename T, ARM_COMPUTE_REQUIRES_TA(traits::is_
floating_po
int<T>::value)>
124 return std::floor(value + 0.5f);
135 template <
typename T, ARM_COMPUTE_REQUIRES_TA(traits::is_
floating_po
int<T>::value)>
138 return std::ceil(value - 0.5f);
150 template <
typename T, ARM_COMPUTE_REQUIRES_TA(traits::is_
floating_po
int<T>::value)>
153 T positive_value = std::abs(value);
155 std::modf(positive_value, &ipart);
157 if (std::abs(positive_value - (ipart + 0.5f)) <
epsilon)
160 if (std::fmod(ipart, 2.f) <
epsilon)
180 template <
typename T, ARM_COMPUTE_REQUIRES_TA(traits::is_
floating_po
int<T>::value)>
183 switch (rounding_mode)