This function will format a value expressed as feet (with decimals) into feet and inches. // Convert feet (decimal) into feet and inches function toString(value) { var abs = Math.abs(value); // Round to nearest 0.1 inch var rounded = Math.round(120 * abs) / 120; var feet = Math.floor(rounded); var inches = 12*(rounded – feet); return […]
As a part of a calculator for model railroad stub switches, I developed a couple of javascript routines for input and output that allow more flexibility than the standard implementation. This function converts to text for display from a numeric value, with a variable number of decimals, removing extra trailing zeroes. It also converts the (default […]