#region Weights
private double StoneToKg(double Stone, double pounds)
{
return (Stone * 14 + pounds) * 0.4535970244035199;
}
private double[] KgToStone(double p)
{
double T = (p * 0.1574714285714286);
double Stn = Math.Floor(T);
double Pounds = (T - Stn) * 14;
return new double[2] { Stn, Pounds };
}
#endregion
#region Heights
private double CmToM(double Cm)
{
return Cm * 0.01;
}
private double MToCm(double M)
{
return M * 100;
}
private double FeetToMeters(double Feet, double inch)
{
Feet *= 12;
return (Feet + inch) * 0.025399999961392;
}
private double[] MetersToFeet(double Meters)
{
double feet = Math.Floor(Meters * 3.2808399);
double inch = (Meters * 3.2808399) - Math.Floor(Meters * 3.2808399);
inch *= 12;
return new double[2] { feet, inch };
}
private double feetInchToCentimeters(double feet, double inch)
{
return MToCm(FeetToMeters(feet, inch));
}
private double[] CentimetersToFeetInch(double Cm)
{
return MetersToFeet(CmToM(Cm));
}
#endregion
This is the conversion code I'm using, currently having issues converting from stone to kg and back (100 stn 0 pounds to kg and back gives 107 stn and 2.00000000000014 pounds) but converting 100 kg to stone and back works, I think it's rounding the answer but I am unsure where or how to fix, looking for a way to make an accurate conversion which can handle conversions to and from.
Any other code tying and suggestions are welcome however.
(I included the height conversions in-case there is a problem with that too).