Closed n2b8 closed 8 years ago
I don't remember well for the mathematical part of it but I guess it should work with farenheit as well. Did you check it?
i know the formula should be C * 9/5 + 32 = F (it isn't exact but it's close enough) I tried adding it in to the deltaT calculation but it was giving me really high levels for some reason. Again I'm probably just way over thinking it and wasn't sure if you had already come up with a solution that I wasn't seeing. If not no big deal.
what about if you convert your input to C and the output back to farenheit?
Yep that's what I ended up doing. Much easier. Thanks for your quick help! In case anyone else is wondering these are the functions I created to get the most accurate conversion.
var toCelsius = function (tempF) {
var fahrenheitInt = parseFloat(tempF, 10);
var celsiusTemp = (fahrenheitInt - 32) * 5/9;
var celsiusRounded = celsiusTemp.toFixed(10);
var celsiusString = celsiusRounded.toString();
return celsiusString;
};
var toFahrenheit = function (tempC) {
var celsiusInt = parseFloat(tempC, 10);
var fahrenheitTemp = celsiusInt * 9/5 + 32;
var fahrenheitRounded = fahrenheitTemp.toFixed(0);
var fahrenheitString = fahrenheitRounded.toString();
return fahrenheitString;
};
@n2b8 you can send a pr about adding these to tools to the lib. Maybe would be useful for others as well.
I'm sure I'm making this way more complicated than necessary, however is there an easy way to convert this to Fahrenheit?