MGCJerry
07-31-2005, 01:37 AM
I'm coding a script that converts the US measurements to metric system and vice versa.
I'm having difficulty optimizing the meters to feet/inches code. It is functional and works, but I'm wondering if there is a way to clean it up a bit and make it more efficient.
In this code the variable, $char[ISheight] is in meters with a decimal.
$f = sprintf("%01.1s",$char[ISheight]*39.3700787/12);
$i = sprintf("%01.3f",$char[ISheight]*39.3700787/12-$f);
$i = sprintf("%01.0f",$i/0.08333);
$char[USheight] = " $f', $i\"";
Thanks in advance. :)
I'm having difficulty optimizing the meters to feet/inches code. It is functional and works, but I'm wondering if there is a way to clean it up a bit and make it more efficient.
In this code the variable, $char[ISheight] is in meters with a decimal.
$f = sprintf("%01.1s",$char[ISheight]*39.3700787/12);
$i = sprintf("%01.3f",$char[ISheight]*39.3700787/12-$f);
$i = sprintf("%01.0f",$i/0.08333);
$char[USheight] = " $f', $i\"";
Thanks in advance. :)
