C code converting two’s complement data into signed long int

ADC ICs (e.g., ADS1256, ADS1246) often outputs an analog voltage value in the format of  2’s complement.  I am sharing a simple function and example that convert the format of two’s complement into signed long int.

for the detailed knowledge on the format of 2’s complement, please refer this site.

https://en.wikipedia.org/wiki/Two%27s_complement

I hope this post is helpful for your projects.

Leave a Reply