Scottapotamas / xsens-mti

C library for managing and reading xsens MTi IMU modules over serial.
Apache License 2.0
39 stars 5 forks source link

Resolve negative value handling in fixed-point Q16.32 -> double conversion function #11

Closed Scottapotamas closed 1 year ago

Scottapotamas commented 1 year ago

Failing test case added in 0775155a31ea4a8f045ff67a0477f0acb06df19a.

The issue is due to incorrect handling of signed values in these functions:

https://github.com/Scottapotamas/xsens-mti/blob/0775155a31ea4a8f045ff67a0477f0acb06df19a/src/xsens_utility.c#L126-L134

Consider doing this the longform way - detect sign bit, perform 2's complement aware conversion?