Fix conversion from float to quint16 in SunSpecDataPoint::convertFromFloatWithSSF
Calling this function with a negative value and DataType::Int16 always gives a 0 result on ARM. Need to convert to qint16 first to avoid undefined behavior (cf. https://embeddeduse.com/2013/08/25/casting-a-negative-float-to-an-unsigned-int/)pull/219/head
parent
2904533b05
commit
f819b8d678
|
|
@ -714,7 +714,7 @@ QVector<quint16> SunSpecDataPoint::convertFromFloatWithSSF(float value, qint16 s
|
|||
break;
|
||||
}
|
||||
case Int16: {
|
||||
quint16 rawValue = static_cast<quint16>(value * pow(10, -1 * scaleFactor));
|
||||
quint16 rawValue = static_cast<qint16>(value * pow(10, -1 * scaleFactor));
|
||||
rawData << rawValue;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue