diff --git a/inc/msp/ByteVector.hpp b/inc/msp/ByteVector.hpp index 1831613..931b4d9 100644 --- a/inc/msp/ByteVector.hpp +++ b/inc/msp/ByteVector.hpp @@ -319,11 +319,14 @@ class ByteVector : public std::vector { typename std::enable_if::value, T2>::type* = nullptr> bool unpack(T1& val, T2 scale, T2 offset = 0) const { + using cast_type = std::common_type_t; + bool rc = true; encoding_T tmp = 0; rc &= unpack(tmp); - val = static_cast(tmp) / scale; - val -= offset; + val = static_cast(static_cast(tmp) / + static_cast(scale) - + static_cast(offset)); return rc; }