raiden00pl commented on code in PR #15573: URL: https://github.com/apache/nuttx/pull/15573#discussion_r1918084794
########## drivers/sensors/sht4x_uorb.c: ########## @@ -411,19 +410,13 @@ static int sht4x_reset(FAR struct sht4x_dev_s *priv) * Name: sht4x_calc_temp * * Description: - * Calculate the temperature from the SHT4X raw data. + * Calculate the temperature in degrees Celsius from the SHT4X raw data. * ****************************************************************************/ -static int32_t sht4x_calc_temp(uint16_t temp) +static float sht4x_calc_temp(uint16_t temp) { -#ifdef CONFIG_SHT4X_FAHRENHEIT - /* Millidegrees Fahrenheit */ - - return -49000 + 315 * ((temp * 1000) / 65535); -#else - return -45000 + 175 * ((temp * 1000) / 65535); /* Millidegrees Celsius */ -#endif + return (float)(-45000 + 175 * ((temp * 1000) / 65535)) / 1000.0; Review Comment: please add `f` suffix to all floats like `1000.0f`. Otherwise the compiler may use `double` in some cases. ########## drivers/sensors/sht4x_uorb.c: ########## @@ -411,19 +410,13 @@ static int sht4x_reset(FAR struct sht4x_dev_s *priv) * Name: sht4x_calc_temp * * Description: - * Calculate the temperature from the SHT4X raw data. + * Calculate the temperature in degrees Celsius from the SHT4X raw data. * ****************************************************************************/ -static int32_t sht4x_calc_temp(uint16_t temp) +static float sht4x_calc_temp(uint16_t temp) { -#ifdef CONFIG_SHT4X_FAHRENHEIT - /* Millidegrees Fahrenheit */ - - return -49000 + 315 * ((temp * 1000) / 65535); -#else - return -45000 + 175 * ((temp * 1000) / 65535); /* Millidegrees Celsius */ -#endif + return (float)(-45000 + 175 * ((temp * 1000) / 65535)) / 1000.0; Review Comment: please add `f` suffix to all `float`s like `1000.0f`. Otherwise the compiler may use `double` in some cases. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org