In spite of its strange, illogical relationship between units, we still cling to the English system in the US.
There was a national attempt to get people to convert to metric a number of years ago (some of the gas station pumps even converted to liters), but it didn't stick.
So we have the fun of needing two sets of wrenches and trying to determine whether the bolt we need to replace is metric or English, with the hardware store having to stock both types.
Looking at the code again, it should actually be a loop with the test at the start [eg. while() - do] otherwise an input less than 12 inches will give an erroneous result.
Then use the concept that 1/4 + 1/16 + 1/64 + 1/256 + ... = 1/3
(Note that each are two (additional) shifts to right. Put the shifts in a loop until a two-bit shift results in no change (zero).
Also, add 1 to the value to be divided by 3 before dividing to cover a rounding error.
Much faster if you have large inch values to convert.
Search StackOverflow for divide by 3 for details. Very compact code can be written to handle very large inch values in a few steps.
Instead of dividing by four at the beginning you could simply remove the addition of 1/4...
1/16 + 1/64 + 1/256 + ... = 1/12
.... but how do you determine the "magic" series of numbers to add?
In this example we wanted to divide by 12
1) Find the reciprocal of 12 which is 0.08333333333333 ... 1/12 = 0.08333333333333
2) Determine the bit resolution multiplier ... for this example 8 bits of resolution = 256 ... 8^2 = 256
3) Multiply Step 1 by Step 2 and you get 21.33333333333
4) Round step 3 and convert it to Binary. The result is ... 00010101
5) On the left most side(MSB), the binary fractional weight starts at 1/2 and ends at 1/256 on the right most side(LSB). Where there is a "1" in the binary sequence you simply add that to the previous result.
MSB - 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256 - LSB
6) So it becomes ....
1/16 + 1/64 + 1/256 + ... = 1/12
1 furlong / fortnight = 0.000166309524 meters / second (LOL)
I can not remember; there is a measurement of land where a farm family can survive on. (old English) Only problem is this depends on water, weather, soil type and how hard you whip the farmer. Many farmers starved.
Now that we (the UK) are leaving the European Union, there are those would would have us abandon the SI unit system and return to the old illogical Imperial Units, inches, feet, yards, ounces, pounds, stones etc.
Now that we (the UK) are leaving the European Union, there are those would would have us abandon the SI unit system and return to the old illogical Imperial Units, inches, feet, yards, ounces, pounds, stones etc.
Illogical? Owing back to non-si units. Last time I was in the U.K., those traffic signs with a number in a red circle were calibrated in miles per hour instead of kmh like real metric countries.
What is the official definition of a mile in the U.K.? Are other non-metric units used (8-furlongs, 5,280 feet or 1,760 yards - and how are those defined?). In the US, an inch is officially defined as 2.54mm EXACTLY and all units flow from there.
Last time I was in the U.K., those traffic signs with a number in a red circle were calibrated in miles per hour instead of kmh like real metric countries.
Correct.
To this day, roadsign distances are in miles and speed limits are in miles per hour.
We never did get around to changing those things.
Similarly if we go to the pub, we may have a pint of beer. Litres, what are they?
But when I go shopping for groceries, weights are in (kilo)grams, and volumes are in (milli)litres.
In the world of engineering, all measurements are in SI units with a few odd exceptions.
Material sizes, wood, metal etc are often specified in Imperial sizes.
The sizes of wood blows my mind, it never seems to be the size stated, whatever units are used.
The oil industry can be a bit odd.
The drilling people mostly seem to work in Imperial units, feet, pounds, pounds per square inch, but the topside process people work in SI units.