Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clamp before downcasting in float to i8 conversions
Previously we were downcasting floats to the target type (e.g. int8_t), and then clamping to [-100, 100] range. This means that e.g. 129 would be cast to -127 and then converted to -100, in stead of becoming 100 The fix does clamping first, and then casts the resulting number (which is guaranteed to be in range [-100, 100], due to clamping) from source type to target int8_t. Given the clamping, this will never overflow.
- Loading branch information