Most days I watch one or two videos from a Lynda.com course (affiliate link). It’s fantastic ongoing training.
A great Unix course
The course I’m working through now is Unix for Mac OS X Users, by Kevin Skoglund.
He’s explained things like Users and Permissions and shared some great information about working with text, handling files, hard and symbolic links, and working with processes.
It’s fascinating and helpful stuff and he delivers the course really well.
But of course, that’s standard for the Lynda courses.
A strange problem
In the video Utility programs Skoglund mentions a unit conversion utility called Units, and he shows us how it works with a few conversions from feet to metres and gallons to litres. It looks very handy.
But then he converted 72 degrees Fahrenheit to Celsius. 72°F is a pleasant, mild day.
But the answer that Units pops out is 40°C — a stinking hot day!
Skoglund seems to be an American, so I guess this oddity didn’t leap out at him the way it leapt out at me.
When I was a kid New Zealand used the old imperial measures. Then in the 1970s, when I was a teenager, we switched to metric measures.
I recall one day as a schoolgirl at Girls’ High in Christchurch watching the temperature display on some public building in Cathedral Square as it approached and then exceeded 100°F. It was an extremely hot day! A mere 72°F is nothing!
So one thing we learned early was that to convert Fahrenheit to Celsius you first subtract 32, then divide by 9 and multiply by 5.
72-32 = 40 40/9 = 4 (rounded) 4*5 = 20
So, 72°F is around 20°C. Actually it’s 22.2. But it’s definitely not 40!
So who’s wrong?
Clearly either Skoglund had entered incorrect data or the Units program is actually wrong.
Man units in Terminal told me the actual file is at
/usr/share/misc/units.lib, so I opened it up and took a look.
It appears that Units has degrees Fahrenheit as degrees Celsius divided by 9 and multiplied by 5, but without subtracting 32 first. The screenshot here shows that. And that formula would certainly give the incorrect answer of 40.
How to report this problem?
If this were a standard Mac app, such as Calculator, I’d file an error report with Apple. But I’m not sure of my ground, or the process for these Unix files. I’ve reported the anomaly to Lynda.com, but what next?
In any case, if you use Units then don’t use it for converting temperatures.
Update August 2015. Chris emailed to say:
I ran into the same thing while using units recently, and thought about raising a bug report.
However it turns out this behaviour is both intended and documented. What units is telling you is that a *change* in temperature of 72 degF is equal to a change of 40 degC.
To perform a straight conversion:
You have: tempF(72)
You want: tempC
Search for “NONLINEAR UNIT CONVERSIONS” in the units documentation for more information.