Skip to content

Commit

Permalink
Use correct float version of expensive math operations
Browse files Browse the repository at this point in the history
  • Loading branch information
da-phil committed Jun 2, 2024
1 parent 1c58e68 commit fe4bddc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions DHT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ float DHT::computeHeatIndex(float temperature, float percentHumidity,
if (hi > 79.F) {
hi = -42.379F + 2.04901523F * temperature + 10.14333127F * percentHumidity +
-0.22475541F * temperature * percentHumidity +
-0.00683783F * pow(temperature, 2.F) +
-0.05481717F * pow(percentHumidity, 2.F) +
0.00122874F * pow(temperature, 2.F) * percentHumidity +
0.00085282F * temperature * pow(percentHumidity, 2.F) +
-0.00000199F * pow(temperature, 2.F) * pow(percentHumidity, 2.F);
-0.00683783F * powf(temperature, 2.F) +
-0.05481717F * powf(percentHumidity, 2.F) +
0.00122874F * powf(temperature, 2.F) * percentHumidity +
0.00085282F * temperature * powf(percentHumidity, 2.F) +
-0.00000199F * powf(temperature, 2.F) * powf(percentHumidity, 2.F);

if ((percentHumidity < 13.F) && (temperature >= 80.0F) &&
(temperature <= 112.0F))
hi -= ((13.0F - percentHumidity) * 0.25F) *
sqrt((17.0F - abs(temperature - 95.0F)) * 0.05882F);
sqrtf((17.0F - abs(temperature - 95.0F)) * 0.05882F);

else if ((percentHumidity > 85.0F) && (temperature >= 80.0F) &&
(temperature <= 87.0F))
Expand Down

0 comments on commit fe4bddc

Please sign in to comment.