Skip to content

Fixed decoder function for negative temperatures #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2018
Merged

Fixed decoder function for negative temperatures #11

merged 1 commit into from
Feb 8, 2018

Conversation

samvanbrussel
Copy link
Contributor

When negative numbers in 2-complement get converted from 16-bit (Arduino) to 32-bit (JavaScript), the sign bit has to be at bit 0, not at bit 17, as it was with the old code, which implicitly padded 16 zeroes to the left. As a result, the negative number -1 returns 65535.

By prefixing a 16-bit negative number with 16 ones, the correct 32-bit 2-complement number is constructed.

@CLAassistant
Copy link

CLAassistant commented Feb 7, 2018

CLA assistant check
All committers have signed the CLA.

@johanstokking johanstokking self-requested a review February 8, 2018 13:28
@johanstokking johanstokking self-assigned this Feb 8, 2018
Copy link
Member

@johanstokking johanstokking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

It's a cold winter indeed

@johanstokking johanstokking merged commit 832a9b5 into TheThingsNetwork:master Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants