From 9d6de78cd79711f02bbc74097fc3f0dbff5d73ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Sun, 16 Jul 2023 11:18:02 +0200 Subject: [PATCH] fix linux compile issue --- WickedEngine/wiRandom.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/WickedEngine/wiRandom.h b/WickedEngine/wiRandom.h index abf531c39..6ad306a16 100644 --- a/WickedEngine/wiRandom.h +++ b/WickedEngine/wiRandom.h @@ -30,12 +30,12 @@ namespace wi::random // gives an uint64 in range [min, max] constexpr uint64_t next_uint(uint64_t min, uint64_t max) { - return min + (next_uint() % (std::min(std::numeric_limits::max() - 1ull, std::max(1ull, max - min)) + 1ull)); + return min + (next_uint() % (std::min(std::numeric_limits::max() - uint64_t(1), std::max(uint64_t(1), max - min)) + uint64_t(1))); } // gives an uint32 in range [min, max] constexpr uint32_t next_uint(uint32_t min, uint32_t max) { - return min + (uint32_t(next_uint()) % (std::min(std::numeric_limits::max() - 1u, std::max(1u, max - min)) + 1u)); + return min + (uint32_t(next_uint()) % (std::min(std::numeric_limits::max() - uint32_t(1), std::max(uint32_t(1), max - min)) + uint32_t(1))); } // gives an int64 in range [-INT64_MAX, INT64_MAX] @@ -47,12 +47,12 @@ namespace wi::random // gives an int64 in range [min, max] constexpr int64_t next_int(int64_t min, int64_t max) { - return min + int64_t(next_uint() % (std::min(std::numeric_limits::max() - 1ll, std::max(1ll, max - min)) + 1ll)); // we roll next_uint here to avoid negative value messing with range mapping + return min + int64_t(next_uint() % (std::min(std::numeric_limits::max() - int64_t(1), std::max(int64_t(1), max - min)) + int64_t(1))); // we roll next_uint here to avoid negative value messing with range mapping } // gives an int32 in range [min, max] constexpr int32_t next_int(int32_t min, int32_t max) { - return min + int32_t(next_uint() % (std::min(std::numeric_limits::max() - 1, std::max(1, max - min)) + 1)); // we roll next_uint here to avoid negative value messing with range mapping + return min + int32_t(next_uint() % (std::min(std::numeric_limits::max() - int32_t(1), std::max(int32_t(1), max - min)) + int32_t(1))); // we roll next_uint here to avoid negative value messing with range mapping } // gives a float in range [0, 1]