BAN: Add big_endian_to_host in Math

This commit is contained in:
Bananymous 2023-02-23 15:58:32 +02:00
parent 5cd97e44e2
commit 6c1f0d1dc8
1 changed files with 9 additions and 0 deletions

View File

@ -60,4 +60,13 @@ namespace BAN::Math
return result; return result;
} }
template<integral T>
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;
}
} }