From: <sv...@op...> - 2024-12-18 15:45:31
|
Author: manx Date: Wed Dec 18 16:45:24 2024 New Revision: 22567 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22567 Log: [Ref] mpt/endian/floatingpoint.hpp: Add get() and set(), like for packed integers. Modified: trunk/OpenMPT/src/mpt/endian/floatingpoint.hpp Modified: trunk/OpenMPT/src/mpt/endian/floatingpoint.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/endian/floatingpoint.hpp Wed Dec 18 16:07:45 2024 (r22566) +++ trunk/OpenMPT/src/mpt/endian/floatingpoint.hpp Wed Dec 18 16:45:24 2024 (r22567) @@ -160,6 +160,13 @@ MPT_FORCEINLINE operator somefloat32() const { return DecodeIEEE754binary32(GetInt32()); } + MPT_FORCEINLINE self_t & set(somefloat32 f) { + SetInt32(EncodeIEEE754binary32(f)); + return *this; + } + MPT_FORCEINLINE somefloat32 get() const { + return DecodeIEEE754binary32(GetInt32()); + } MPT_FORCEINLINE self_t & SetInt32(uint32 i) { bytes[hihi] = static_cast<std::byte>(i >> 24); bytes[hilo] = static_cast<std::byte>(i >> 16); @@ -216,6 +223,13 @@ MPT_FORCEINLINE operator somefloat64() const { return DecodeIEEE754binary64(GetInt64()); } + MPT_FORCEINLINE self_t & set(somefloat64 f) { + SetInt64(EncodeIEEE754binary64(f)); + return *this; + } + MPT_FORCEINLINE somefloat64 get() const { + return DecodeIEEE754binary64(GetInt64()); + } MPT_FORCEINLINE self_t & SetInt64(uint64 i) { bytes[hihihi] = static_cast<std::byte>(i >> 56); bytes[hihilo] = static_cast<std::byte>(i >> 48); @@ -315,6 +329,13 @@ MPT_FORCEINLINE operator somefloat32() const { return value; } + MPT_FORCEINLINE IEEE754binary32Native & set(somefloat32 f) { + value = f; + return *this; + } + MPT_FORCEINLINE somefloat32 get() const { + return value; + } MPT_FORCEINLINE IEEE754binary32Native & SetInt32(uint32 i) { value = DecodeIEEE754binary32(i); return *this; @@ -365,6 +386,13 @@ MPT_FORCEINLINE operator somefloat64() const { return value; } + MPT_FORCEINLINE IEEE754binary64Native & set(somefloat64 f) { + value = f; + return *this; + } + MPT_FORCEINLINE somefloat64 get() const { + return value; + } MPT_FORCEINLINE IEEE754binary64Native & SetInt64(uint64 i) { value = DecodeIEEE754binary64(i); return *this; |