Skip to content

Commit b34be08

Browse files
authored
Merge pull request #172 from dirkmueller/master
Use float for calculations between Fahrenheit and Celcius
2 parents b67d877 + 0d96890 commit b34be08

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

DallasTemperature.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -722,12 +722,12 @@ void DallasTemperature::setUserDataByIndex(uint8_t deviceIndex, int16_t data) {
722722

723723
// Convert float Celsius to Fahrenheit
724724
float DallasTemperature::toFahrenheit(float celsius) {
725-
return (celsius * 1.8) + 32;
725+
return (celsius * 1.8f) + 32.0f;
726726
}
727727

728728
// Convert float Fahrenheit to Celsius
729729
float DallasTemperature::toCelsius(float fahrenheit) {
730-
return (fahrenheit - 32) * 0.555555556;
730+
return (fahrenheit - 32.0f) * 0.555555556f;
731731
}
732732

733733
// convert from raw to Celsius
@@ -736,7 +736,7 @@ float DallasTemperature::rawToCelsius(int16_t raw) {
736736
if (raw <= DEVICE_DISCONNECTED_RAW)
737737
return DEVICE_DISCONNECTED_C;
738738
// C = RAW/128
739-
return (float) raw * 0.0078125;
739+
return (float) raw * 0.0078125f;
740740

741741
}
742742

@@ -747,7 +747,7 @@ float DallasTemperature::rawToFahrenheit(int16_t raw) {
747747
return DEVICE_DISCONNECTED_F;
748748
// C = RAW/128
749749
// F = (C*1.8)+32 = (RAW/128*1.8)+32 = (RAW*0.0140625)+32
750-
return ((float) raw * 0.0140625) + 32;
750+
return ((float) raw * 0.0140625f) + 32.0f;
751751

752752
}
753753

0 commit comments

Comments
 (0)