From e14f27f41268a11c34299a8b94a380b28c6b71e9 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 8 Aug 2023 14:18:26 +0200 Subject: [PATCH] Add cautionary note about sat_mul() --- TileGenerator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TileGenerator.cpp b/TileGenerator.cpp index a28ae67..8a5d9d7 100644 --- a/TileGenerator.cpp +++ b/TileGenerator.cpp @@ -43,6 +43,8 @@ inline T sat_mul(T a, T b) return std::numeric_limits::max(); return res; #else + // WARNING: the fallback implementation is incorrect since we compute ceil(log(x)) not log(x) + // but that's good enough for our usecase... const int bits = sizeof(T) * 8; int hb_a = 0, hb_b = 0; for (int i = bits - 1; i >= 0; i--) {