I'd like to convert kilos into pounds and ounces e.g. if a user enters 10 kg then the function should return 22 lb and 0.73 oz
Any ideas?
I'd like to convert kilos into pounds and ounces e.g. if a user enters 10 kg then the function should return 22 lb and 0.73 oz
Any ideas?
function kgToPounds(value) {
return value * ?conversionValue?;
}
Replace ?conversionValue?
to whatever the rate needs to be.
function poundsToOunces(value) {
return value * 16;
}
Not really hard stuff, this.
function KtoLbs(pK) {
nearExact = pK/0.45359237;
lbs = Math.floor(nearExact);
oz = (nearExact - lbs) * 16;
}
/* sigh */
Based on @dlamblin's answer, here's a function that returns the pounds and ounces in a structure.
function KtoLbs(pK) {
var nearExact = pK/0.45359237;
var lbs = Math.floor(nearExact);
var oz = (nearExact - lbs) * 16;
return {
pounds: lbs,
ounces: oz
};
}
var imperial = KtoLbs(10);
alert("10 kg = " + imperial.pounds + " lbs and " + imperial.ounces + " oz.");
Google almost does it. Wont do pounds and ounces.
Google "10 kg in ounces"
Google responds: 10 kilograms = 352.739619 ounces
Then all you'd have to do is write all the plumbing to send the info to google and get it back.
:-)