Jul. 22nd, 2021

solarbird: (Default)
If for some dumbass reason you ever need to take temperature data reported to a fake accuracy of 0.01°F and produce a much more reasonable number in °C rounded to the nearest 0.5°C and do it in a single line of PHP code, HERE YOU GO:

intval(($fpTempF-31.95)/1.8)+round(2*((($fpTempF-31.95)/1.8)-intval(($fpTempF-31.95)/1.8)))/2

If the way your data collectors report values have a little less "...why?" involved, you can change the 31.95 to 32.

I may do it anyway.

Or I may not bother, honestly, it's 0.05 of noise in a digit position that is already made of noise.

The best part is that it works on literally anything made since CSS happened. So like... 1998. I tested the display on an original iPhone. It works fine.

June 2025

S M T W T F S
1 234567
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags