adafruit / Adafruit_BME280_Library

Arduino Library for BME280 sensors
Other
333 stars 304 forks source link

Sign-extend Humidity Calibration H4/H5 data (Fixes #44) #56

Closed dirkmueller closed 4 years ago

ladyada commented 5 years ago

hiya why'd ya need to double-cast? never seen it befoer :)

dirkmueller commented 5 years ago

the first (inner) cast is a sign conversion (treating the read value as signed 8bit integer). the outer cast is a small optimisation, it changes the bitwise | and << operation to operate on signed 16bits (because we only store signed 16 bit integer anyway) instead of a machine specific int promotion (typically 32/64bit) (which would be the default in C/C++). I can remove that outer cast, it would not matter, the inner cast is the actual change. just let me know, I'll update it then.

ladyada commented 5 years ago

oki thanks for the details - we'll have to test on hardware

ladyada commented 4 years ago

thanx!