mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:27:45 +00:00
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:
parent
29e0494e56
commit
c9808f0d4a
1 changed files with 13 additions and 2 deletions
15
AK/Math.h
15
AK/Math.h
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue