Both use INT and the same delta logic, so they seem equivalent. However, when an overflow (wrap-around) occurs, version A continues correctly as expected, while version B unexpectedly resets to -32768 without a clear reason.
Has anyone experienced similar behavior or can shed light on what might be happening here?
It almost seems as if the cast to LREAL is being applied before the calculation β but that would be illogical and potentially very dangerous in many situations!
Thanks!
Last edit: mondinmr 2025-05-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone,
Iβm investigating a potential issue with a cyclic method we use for reading incremental encoders in our libraries.
Iβve come across two implementations that, at first glance, appear to perform the same operation:
motionUnit.vlPositionActualValue is UINT due strange encoder type.
Version A
Version B
Both use INT and the same delta logic, so they seem equivalent. However, when an overflow (wrap-around) occurs, version A continues correctly as expected, while version B unexpectedly resets to -32768 without a clear reason.
Has anyone experienced similar behavior or can shed light on what might be happening here?
It almost seems as if the cast to LREAL is being applied before the calculation β but that would be illogical and potentially very dangerous in many situations!
Thanks!
Last edit: mondinmr 2025-05-13