Skip to content

Fixed decoder function for negative temperatures#11

Merged
johanstokking merged 1 commit intoTheThingsNetwork:masterfrom
samvanbrussel:master
Feb 8, 2018
Merged

Fixed decoder function for negative temperatures#11
johanstokking merged 1 commit intoTheThingsNetwork:masterfrom
samvanbrussel:master

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