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.

April 2026

S M T W T F S
   1234
5 6 7891011
12131415161718
19202122232425
2627282930  

Most Popular Tags