• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Inches and feet.

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
The quickest way on a micro is a loop taking 12 from inches and counting feet.

feet = 0
loop
inches -= 12​
feet++​
while inches > 12​

You'll be left with feet and inches.. Divide is slow on a micro..
 

ronsimpson

Well-Known Member
Most Helpful Member
Really hard to keep track of English units of length.
Thou or mill, line, inch, foot, yard, furlong, mile, league.
 

crutschow

Well-Known Member
Most Helpful Member
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. :eek:
 

KeepItSimpleStupid

Well-Known Member
Most Helpful Member
The inch and the foot are body part measurements. I'm constantly remided what 1', 2' and 4' are: floor and ceiling tiles.

I know what a mile is by walking and having it measured. By estimate is from my house to xyz.

I hate the unit pascals for pressure. It's too big.

Then I ordered 3m IEEE-488 cables instead of 3 foot long ones..

I don;t mind 0.001 inches. Then there is numbered, lettered and fractional drills.
 

alec_t

Well-Known Member
Most Helpful Member

crutschow

Well-Known Member
Most Helpful Member
You get short-changed on your 'gallon', for example.
Yes, I have no idea why there are two different sizes for that.

Also have the sort ton and the long (Imperial) ton.
Interesting the the long ton is within about 1.6% of the metric ton (tonne).
 
Last edited:

rjenkinsgb

Well-Known Member
Most Helpful Member
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.
 

gophert

Well-Known Member
Most Helpful Member
First divide by four (right shift by 2 bits);

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.
 

JimB

Super Moderator
Most Helpful Member
Then use the concept that 1/4 + 1/16 + 1/64 + 1/256 + ... = 1/3
Interesting gophert, I did not know that.
Or if I did, I had forgotten it long ago.

JimB
 

Beau Schwabe

Active Member
Ahh, Division by way of Multiplying..

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
 

ronsimpson

Well-Known Member
Most Helpful Member
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.
 

JimB

Super Moderator
Most Helpful Member
Now that we (the UK) are leaving :facepalm: 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.
:facepalm::facepalm::facepalm::facepalm:

JimB
 

gophert

Well-Known Member
Most Helpful Member
Now that we (the UK) are leaving :facepalm: 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.
:facepalm::facepalm::facepalm::facepalm:

JimB
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.
 

JimB

Super Moderator
Most Helpful Member
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.

JimB
 

Latest threads

EE World Online Articles

Loading

 
Top