mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-24 16:40:21 +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
Notes:
sideshowbarker
2024-07-16 20:51:53 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/c9808f0d4a Pull-request: https://github.com/SerenityOS/serenity/pull/18998 Reviewed-by: https://github.com/kleinesfilmroellchen ✅ Reviewed-by: https://github.com/linusg ✅
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…
Reference in a new issue