FixedPointsArduino
FixedPointsArduino copied to clipboard
Replace use of LargerType in constructors with ShiftType
This change would have two potential benefits:
- The undefined behaviour eminating from
<<with a negative left hand value would be replaced with the well-defined behaviour of an unsigned type. - Theoretically this should generate less code because the code would no longer be using unnecessary excess bytes during the shift operation. Whether this is true in practice would have to be tested - the compiler may already be optimising this.
The code should be functionally equivalent, hence this should be a 'patch' change.
As a reminder:
static_cast<InternalType>(static_cast<ShiftType>(value) << FractionSize)