From 6c1f0d1dc87b66d66cdeffbba27d89186de60bbc Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 23 Feb 2023 15:58:32 +0200 Subject: [PATCH] BAN: Add big_endian_to_host in Math --- BAN/include/BAN/Math.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/BAN/include/BAN/Math.h b/BAN/include/BAN/Math.h index e0778ebb1..fa05875d4 100644 --- a/BAN/include/BAN/Math.h +++ b/BAN/include/BAN/Math.h @@ -60,4 +60,13 @@ namespace BAN::Math return result; } + template + inline constexpr T big_endian_to_host(const uint8_t* bytes) + { + T result = 0; + for (size_t i = 0; i < sizeof(T); i++) + result |= (T)bytes[i] << (8 * (sizeof(T) - i - 1)); + return result; + } + } \ No newline at end of file