Blog‎ > ‎

Always check your input ranges

posted Dec 14, 2010, 5:42 AM by Lewis Baumstark   [ updated Dec 14, 2010, 5:46 AM ]

epic fail photos - Temperature FAIL
see more funny videos

My speculation on what went wrong: I'm guessing the raw output of the temperature sensor is stored (in software) using an unsigned 8-bit integer. This integer would have a range of 0-255 internally, but those are probably mapped to a different range of Fahrenheit (F) values. Since the display is showing +266F, let's assume +266F = 255 stored, so our lowest measurable value of F is +266-255+1 = +12F.   This would give us a range of displayable values from +12F to +266F.

Assuming these values are correct (they're certainly reasonable on the low end), any time the temperature drops below +12F (the snow in the picture suggests it could easily be that cold), the 8-bit integer is going to overflow -- literally wrapping around and showing values on the upper end of the scale.

By the same token, the display could read -10F when Armageddon sends the ambient temperature to +276F.  :)