Implement ReverseBytes for double properly
This commit is contained in:
parent
ae99701d00
commit
68a2852043
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <bit>
|
||||||
|
|
||||||
namespace Feather
|
namespace Feather
|
||||||
{
|
{
|
||||||
|
@ -28,6 +29,8 @@ namespace Feather
|
||||||
inline int32_t ReverseBytes(int32_t n) { return int32_t(ReverseBytes(uint32_t(n))); }
|
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))); }
|
inline int64_t ReverseBytes(int64_t n) { return int64_t(ReverseBytes(uint64_t(n))); }
|
||||||
|
|
||||||
// FIXME: this maybe very wrong
|
template <typename J, typename T>
|
||||||
inline double ReverseBytes(double d) { return (double)ReverseBytes((uint64_t)d); }
|
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); }
|
||||||
}
|
}
|
Loading…
Reference in New Issue