summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-09-03 07:56:53 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-09-03 07:56:53 +0200
commit2f4d634061fb5a537c1ce0b58a9c985b328a9327 (patch)
tree9b379dd65ce00c96e63c362e949c7dccab7fdff8
parent30e369cf24c0ea99e209b75fba5d65d55ef94aec (diff)
compat/math: fix ceil() for negative numbers
-rw-r--r--compat/math.hpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/compat/math.hpp b/compat/math.hpp
index d5b628c4..8df83cc3 100644
--- a/compat/math.hpp
+++ b/compat/math.hpp
@@ -62,15 +62,11 @@ constexpr inline T ceil(T x)
{
if (std::is_constant_evaluated())
{
-#ifdef __GNUG__
- return __builtin_ceil(x);
-#else
- const auto x0 = uint64_t(x);
+ const auto x0 = int64_t(x);
if (x > x0)
- return T(x0 + uint64_t(1));
+ return T(x0 + int64_t(1));
else
return x0;
-#endif
}
else
return std::ceil(x);