index.js
function (val, type) {
        var ret;
        // allows Num(...) to be used directly without new. For shame!
        if (!(this instanceof Num) ) {
            return new Num(val, type);
        }
    
        this.original = val;
    
        if ((val instanceof Num) && (val.type === "NaN") ) {
            return val;
        }
    
        if (type) {
            this.type = type;
            ret = this.parse();  // will convert original into appropriate val
        } else if (typeof val === "string") {
            ret = Num.tryParse(this);
        } else if (val.type) {
            this.type = val.type;
            ret = this.parse();
        } else if (typeof val === "number") {
            if (Math.floor(val) === val) {
                ret = Num.int(val);
            } else {
                ret = Num.float(val);
            }
        } else {
            ret = false;
        } 
    
        //this.original = val;
    
        if (ret === false) {
            ret = this;
            this.type = "NaN";
            this.val = NaN;
        }   
        if (val instanceof Num) {
            // to make original more viewable for debugging
            if (val.type === "NaN") {
                return val;
            }
            ret.original = val.str();
        }
    
        if (!ret) {
            ret = this;
        }
    
        return ret;
    }
function (val, type) {
        var ret;
        // allows Num(...) to be used directly without new. For shame!
        if (!(this instanceof Num) ) {
            return new Num(val, type);
        }
    
        this.original = val;
    
        if ((val instanceof Num) && (val.type === "NaN") ) {
            return val;
        }
    
        if (type) {
            this.type = type;
            ret = this.parse();  // will convert original into appropriate val
        } else if (typeof val === "string") {
            ret = Num.tryParse(this);
        } else if (val.type) {
            this.type = val.type;
            ret = this.parse();
        } else if (typeof val === "number") {
            if (Math.floor(val) === val) {
                ret = Num.int(val);
            } else {
                ret = Num.float(val);
            }
        } else {
            ret = false;
        } 
    
        //this.original = val;
    
        if (ret === false) {
            ret = this;
            this.type = "NaN";
            this.val = NaN;
        }   
        if (val instanceof Num) {
            // to make original more viewable for debugging
            if (val.type === "NaN") {
                return val;
            }
            ret.original = val.str();
        }
    
        if (!ret) {
            ret = this;
        }
    
        return ret;
    }
/*global module