Z1: tmp102: simple: fixed wrong cast
When using this code: (int8_t)tmp102_read_temp_x100() / 100 Only the first value is casted into a int8_t type. tmp102_read_temp_x100() returns the temperature in Celcius * 100. Most of the time this value will be lower than -2^7 and higher than 2^7 (+/- 1.27°C). The cast is not needed but a comment about this implicit cast has been added.
This commit is contained in:
parent
2cee62eb33
commit
78b6b50194
1 changed files with 2 additions and 1 deletions
|
@ -185,5 +185,6 @@ tmp102_read_temp_x100(void)
|
|||
int8_t
|
||||
tmp102_read_temp_simple(void)
|
||||
{
|
||||
return (int8_t)tmp102_read_temp_x100() / 100;
|
||||
/* Casted to int8_t: We don't expect temperatures outside -128 to 127 C */
|
||||
return tmp102_read_temp_x100() / 100;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue