pica_types: minor cleanup

This commit is contained in:
Vitor Kiguchi 2024-01-20 19:51:18 -03:00
parent eddc4a029c
commit a19166ddec

View file

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <bit>
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include <boost/serialization/access.hpp> #include <boost/serialization/access.hpp>
@ -50,7 +51,7 @@ public:
hex = sign; hex = sign;
} }
std::memcpy(&res.value, &hex, sizeof(float)); res.value = std::bit_cast<float>(hex);
return res; return res;
} }
@ -95,17 +96,17 @@ public:
} }
constexpr Float<M, E>& operator/=(const Float<M, E>& flt) { constexpr Float<M, E>& operator/=(const Float<M, E>& flt) {
value /= flt.ToFloat32(); value = operator/(flt).value;
return *this; return *this;
} }
constexpr Float<M, E>& operator+=(const Float<M, E>& flt) { constexpr Float<M, E>& operator+=(const Float<M, E>& flt) {
value += flt.ToFloat32(); value = operator+(flt).value;
return *this; return *this;
} }
constexpr Float<M, E>& operator-=(const Float<M, E>& flt) { constexpr Float<M, E>& operator-=(const Float<M, E>& flt) {
value -= flt.ToFloat32(); value = operator-(flt).value;
return *this; return *this;
} }