lib/format.js
function UDecimalString(value) {
    assert(value != null, "value is required");
    value = value === "object" && value.toString ? value.toString() : String(value);

    if (value[0] === ".") {
        value = '0' + value;
    }

    var part = value.split(".");
    assert(part.length <= 2, 'invalid decimal ' + value);
    assert(/^\d+(,?\d)*\d*$/.test(part[0]), 'invalid decimal ' + value);

    if (part.length === 2) {
        assert(/^\d*$/.test(part[1]), 'invalid decimal ' + value);
        part[1] = part[1].replace(/0+$/, ""); // remove suffixing zeros
        if (part[1] === "") {
            part.pop();
        }
    }

    part[0] = part[0].replace(/^0*/, ""); // remove leading zeros
    if (part[0] === "") {
        part[0] = "0";
    }
    return part.join(".");
}
function UDecimalString(value) {
    assert(value != null, "value is required");
    value = value === "object" && value.toString ? value.toString() : String(value);

    if (value[0] === ".") {
        value = '0' + value;
    }

    var part = value.split(".");
    assert(part.length <= 2, 'invalid decimal ' + value);
    assert(/^\d+(,?\d)*\d*$/.test(part[0]), 'invalid decimal ' + value);

    if (part.length === 2) {
        assert(/^\d*$/.test(part[1]), 'invalid decimal ' + value);
        part[1] = part[1].replace(/0+$/, ""); // remove suffixing zeros
        if (part[1] === "") {
            part.pop();
        }
    }

    part[0] = part[0].replace(/^0*/, ""); // remove leading zeros
    if (part[0] === "") {
        part[0] = "0";
    }
    return part.join(".");
}
Normalize and validate decimal string (potentially large values).  Should
avoid internationalization issues if possible but will be safe and
throw an error for an invalid number.

Normalization removes extra zeros or decimal.

@return {string} value