From 26ca19b61449e918987aedf7c9df16c7c56aebb8 Mon Sep 17 00:00:00 2001 From: labbbirder <502100554@qq.com> Date: Mon, 9 Oct 2023 20:39:20 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20centos=E4=B8=8B=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deterministic/glacier_float.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deterministic/glacier_float.h b/deterministic/glacier_float.h index 3077bb2..cc46701 100644 --- a/deterministic/glacier_float.h +++ b/deterministic/glacier_float.h @@ -149,7 +149,7 @@ class GFloat // Get Glacier first char "G" for Name { int64_t TValue = (int64_t)b * (int64_t)Traw32 + (int64_t)a; - int32_t index = GBitScanReverse64( (uint64_t)abs(TValue)); + int32_t index = GBitScanReverse64( (uint64_t)std::abs(TValue)); int32_t exp = 62 - index; @@ -235,7 +235,7 @@ class GFloat // Get Glacier first char "G" for Name if (Trawvalue == 0) return GFloat(0, 0); - int32_t index = GBitScanReverse32(abs(Trawvalue)); + int32_t index = GBitScanReverse32(std::abs(Trawvalue)); if (index <= 22) { @@ -254,7 +254,7 @@ class GFloat // Get Glacier first char "G" for Name if( Trawvalue == 0 ) return GFloat(0,0); - int32_t index = GBitScanReverse64(abs(Trawvalue )); + int32_t index = GBitScanReverse64(std::abs(Trawvalue )); if ( index <= 22 ) { @@ -270,7 +270,7 @@ class GFloat // Get Glacier first char "G" for Name inline bool IsNormalize() const { - int32_t absRaw = abs( getfraction()); + int32_t absRaw = std::abs(getfraction()); if ( absRaw !=0 && ( absRaw < 0x00400000 || absRaw > 0x007FFFFF)) { From 2ef1521b0002dbcc532215544fe2c915caebb6aa Mon Sep 17 00:00:00 2001 From: labbbirder <502100554@qq.com> Date: Tue, 10 Oct 2023 19:54:12 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20union=E4=B8=AD=E5=8C=85=E5=90=ABGFlo?= =?UTF-8?q?at=E5=AF=BC=E8=87=B4=E7=BC=96=E8=AF=91=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deterministic/glacier_float.cpp | 2 +- deterministic/glacier_float.h | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/deterministic/glacier_float.cpp b/deterministic/glacier_float.cpp index 0dfbcd3..5604dc5 100644 --- a/deterministic/glacier_float.cpp +++ b/deterministic/glacier_float.cpp @@ -379,7 +379,7 @@ void GFloat::SinCos(const GFloat value, GFloat& OutSin, GFloat& OutCos) } GFloat GFloat::ASin(const GFloat value) { - constexpr GFloat TOne = GFloat::FromRaw32( One().rawint32 ); + GFloat TOne = GFloat::FromRaw32( One().rawint32 ); if( value > TOne) { return Pi_Half(); diff --git a/deterministic/glacier_float.h b/deterministic/glacier_float.h index cc46701..4b41d0c 100644 --- a/deterministic/glacier_float.h +++ b/deterministic/glacier_float.h @@ -15,7 +15,15 @@ #include #include -//#define GLACIER_MULTIPLY_NORAMLIZE_FAST + +/** + * Uncomment the below when you want use GFloat in an union. + * Take in mind that the default value will not guaranteed to be Zero anymore! +*/ +// #define GLACIER_UNION_COMPATIBLE //Fixes compilation error in an union + +// #define GLACIER_MULTIPLY_NORAMLIZE_FAST + #ifndef GLACIER_MULTIPLY_NORAMLIZE_FAST //#define GLACIER_NORMALIZE_TEST @@ -110,12 +118,16 @@ class GFloat // Get Glacier first char "G" for Name static void Init(); +#ifdef GLACIER_UNION_COMPATIBLE + inline GFloat()=default; +#else constexpr GFloat(const GFloat&) = default; constexpr GFloat() : rawint32(0) { } +#endif explicit inline GFloat( int32_t TValue) { @@ -184,7 +196,7 @@ class GFloat // Get Glacier first char "G" for Name static inline constexpr GFloat FromRaw32(int32_t Traw32) { - GFloat T; + GFloat T {0}; T.rawint32 = Traw32; return T; } From 7287adb3cb81846c06e5e48a06b46130fcce48e3 Mon Sep 17 00:00:00 2001 From: labbbirder <502100554@qq.com> Date: Wed, 11 Oct 2023 17:24:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E9=83=A8=E5=88=86=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=99=A8=E6=8A=A5=E9=94=99(invalid-constexpr)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deterministic/glacier_float.cpp | 2 +- deterministic/glacier_float.h | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/deterministic/glacier_float.cpp b/deterministic/glacier_float.cpp index 5604dc5..0dfbcd3 100644 --- a/deterministic/glacier_float.cpp +++ b/deterministic/glacier_float.cpp @@ -379,7 +379,7 @@ void GFloat::SinCos(const GFloat value, GFloat& OutSin, GFloat& OutCos) } GFloat GFloat::ASin(const GFloat value) { - GFloat TOne = GFloat::FromRaw32( One().rawint32 ); + constexpr GFloat TOne = GFloat::FromRaw32( One().rawint32 ); if( value > TOne) { return Pi_Half(); diff --git a/deterministic/glacier_float.h b/deterministic/glacier_float.h index 4b41d0c..e2af5ca 100644 --- a/deterministic/glacier_float.h +++ b/deterministic/glacier_float.h @@ -196,9 +196,7 @@ class GFloat // Get Glacier first char "G" for Name static inline constexpr GFloat FromRaw32(int32_t Traw32) { - GFloat T {0}; - T.rawint32 = Traw32; - return T; + return GFloat(Traw32>>8,Traw32); } static inline constexpr GFloat FromFractionAndExp(int32_t Traw32, int32_t exp)