AK: Use correct builtins for floor and ceil

We were using the double ones, forcing casts to and from them for floats
This commit is contained in:
Hediadyoin1 2023-05-16 15:23:54 +02:00 committed by Andreas Kling
parent 29e0494e56
commit c9808f0d4a
Notes: sideshowbarker 2024-07-16 20:51:53 +09:00

View file

@ -108,7 +108,12 @@ constexpr T ceil(T num)
#if ARCH(AARCH64)
AARCH64_INSTRUCTION(frintp, num);
#else
return __builtin_ceil(num);
if constexpr (IsSame<T, long double>)
return __builtin_ceill(num);
if constexpr (IsSame<T, double>)
return __builtin_ceil(num);
if constexpr (IsSame<T, float>)
return __builtin_ceilf(num);
#endif
}
@ -126,7 +131,12 @@ constexpr T floor(T num)
#if ARCH(AARCH64)
AARCH64_INSTRUCTION(frintm, num);
#else
return __builtin_floor(num);
if constexpr (IsSame<T, long double>)
return __builtin_floorl(num);
if constexpr (IsSame<T, double>)
return __builtin_floor(num);
if constexpr (IsSame<T, float>)
return __builtin_floorf(num);
#endif
}
@ -389,6 +399,7 @@ constexpr T fmod(T x, T y)
return __builtin_fmod(x, y);
#endif
}
template<FloatingPoint T>
constexpr T remainder(T x, T y)
{