Implement ReverseBytes for double properly

This commit is contained in:
Joshua Ashton 2020-08-07 04:09:15 +01:00
parent ae99701d00
commit 68a2852043
1 changed files with 5 additions and 2 deletions

View File

@ -2,6 +2,7 @@
#include <cstdlib>
#include <cstdint>
#include <bit>
namespace Feather
{
@ -28,6 +29,8 @@ namespace Feather
inline int32_t ReverseBytes(int32_t n) { return int32_t(ReverseBytes(uint32_t(n))); }
inline int64_t ReverseBytes(int64_t n) { return int64_t(ReverseBytes(uint64_t(n))); }
// FIXME: this maybe very wrong
inline double ReverseBytes(double d) { return (double)ReverseBytes((uint64_t)d); }
template <typename J, typename T>
inline T ReverseBytesBitcast(T n) { return std::bit_cast<T>(ReverseBytes(std::bit_cast<J>(n))); }
inline double ReverseBytes(double n) { return ReverseBytesBitcast<uint64_t>(n); }
}