Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple formulas to convert weights
Message
 
 
À
07/11/2015 07:58:41
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Science & Medicine
Catégorie:
Mathématiques
Divers
Thread ID:
01627170
Message ID:
01627214
Vues:
26
>>Hi everybody,
>>
>>I just spent about 15 minutes googling and could not find simple formulas I need to implement for conversions of kg into pounds or stones and pounds, pounds into the other 2 and stone and pounds into the other two.
>>
>>Here is what I started to write but I can not find the formulas to use:
>>
>>
>> $scope.updateWeight = function(weight1, weight2, units)
>>            {
>>
>>                switch (units) {
>>                    case 'kg':
>>                        $scope.currentGuest.weightG = weight1 * 1000;
>>                        $scope.currentGuest.weight = Math.round(weight1 * 2.20462); // weight in pounds
>>                        $scope.currentGuest.weightStone = Math.round(weight1 * 0.15747); // weight in stones
>>                        $scope.currentGuest.weigthLbs = // remainder for stones/pounds
>>                        break;
>>                    case 'lbs':
>>                        
>>                        break;
>>
>>                    case 'stones': // stones and pounds
>>                        break;
>>                }
>>            }
>
>Please note that the kilogram is technically a unit of MASS, not of weight. (A weight is a force, and therefore measured in newton.) Pound may be used both for mass and for weight.
>
>The definition of "pounds", unfortunately, varies by country. This is one of several reasons to prefer SI.
>
>To convert between lots of different units of the same type (for example, different mass units), I would suggest you store the equivalent of each unit in some standard - I suggest SI units. For example:
>
>kg = 1 kg
>gram = 0.001 kg
>pound (Avoirdupois) = 0.453592 kg
>pound (Germany) = 0.5 kg
>ton = 1000 kg (also known as "metric ton")
>ton (US) = 907.2 kg
>short ton (US) = 1016 kg
>solar mass = 1.988e30 kg (often used for comparisons in astronomy)
>
>Now, to convert, say, from "ton" to "ton (US)", you would look both up in a table, check that they both convert to the same base units, in this case kg (it makes no sense to convert kilogram to meters, or square meters to meters, though this is a frequent question in online forums...) and then just divide one value by the other.
>
>Similarly, you would store different length units in terms of meters, different area units in terms of square meters, etc.

We're storing values in grams and sm (for height) having extra computed columns for pounds and feet. However, on the form I need to offer different ways to enter information, therefore I need to convert on the fly. For height it's only from sm into feet and inches and vs. versa, for weight it's from kg to pounds or to stones and pounds (or from each of the measurements to the other two). That's why I wrote the method to re-calculate.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform