Value of parsed interger or default value if not a number or < 0
@param  {Any} num value to parse
@param  {Interger} _default default value
@return {Interger} parsing result
438000
function toPositiveInt(num, _default) {
    if (isNumeric(num)) {
        num = parseInt(num, 10);
    } else {
        return _default;
    }
    if (num < 0) {
        return _default;
    }

    return num;
}
973865
function(value, defaultValue) {
      var result = value === undefined || value === null ? defaultValue : value;

      return result;
    }
975200
public int getInt(String key, int defaultValue) {
    if (containsKey(key)) {
      return Integer.parseInt(get(key));
    } else {
      return defaultValue;
    }
  }
22497
def do_int(value, default=0):
    
    try:
        return int(value)
    except (TypeError, ValueError):
        # this quirk is necessary so that "42.23"|int gives 42.
        try:
            return int(float(value))
        except (TypeError, ValueError):
            return default
814236
function /* 9.2.10 */$$core$$GetNumberOption (options, property, minimum, maximum, fallback) {
        var
            // 1. Let value be the result of calling the [[Get]] internal method of
            //    options with argument property.
            value = options[property];

        // 2. If value is not undefined, then
        if (value !== undefined) {
            // a. Let value be ToNumber(value).
            value = Number(value);

            // b. If value is NaN or less than minimum or greater than maximum, throw a
            //    RangeError exception.
            if (isNaN(value) || value < minimum || value > maximum)
                throw new RangeError('Value is not a number or outside accepted range');

            // c. Return floor(value).
            return Math.floor(value);
        }
        // 3. Else return fallback.
        return fallback;
    }
1037977
function nonenum(object, propertyName, defaultValue) {
	var value = object[propertyName];

	if (typeof value === 'undefined') {
		value = defaultValue;
		Object.defineProperty(object, propertyName, {
			enumerable: false,
			value: value
		});
	}

	return value;
}
455551
public function int($value, $min = false, $max = false, $default = false)
	{
		$options = array("options" => array());
		if (isset($default)) {
			$options["options"]["default"] = $default;
		}
		if (is_numeric($min)) {
			$options["options"]["min_range"] = $min;
		}
		if (is_numeric($max)) {
			$options["options"]["max_range"] = $max;
		}

		// We really DO NOT need to validate user inputs like 010 or 0x10
		// so this is not needed: $options["flags"] = FILTER_FLAG_ALLOW_OCTAL | FILTER_FLAG_ALLOW_HEX;
		// If in the code we use something like $this->int(010) this is the
		// same as $this->int(8) - so it will pass and return 8
		// But if we read it from user input, a file etc, it should fail by
		// default. Example Right padding some currencies like 0010.00 USD
		return filter_var($value, FILTER_VALIDATE_INT, $options);
	}
1261716
function toPxValue(value, defaultWidth) {
  // eslint-disable-line complexity
  if (typeof value === 'string') {
    var matched = value.match(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin)$/);

    if (matched) {
      // console.log(matched);
      var size = parseFloat(matched[1]);
      var unit = matched[2];
      value = (0, _utils.sizeToPixel)({
        size: size,
        unit: unit
      });
    } else {
      var _size = Number(value);

      if (!Number.isNaN(_size)) {
        value = _size;
      }
    }
  }

  return value;
}
816882
private Integer parseIntegerFromParam(final String value, final int defaultValue) {
        try {
            return Integer.valueOf(value);
        } catch (NumberFormatException | NullPointerException e) {
            return defaultValue;
        }
    }
127835
public int getInt(String pName, int defaultValue) {
        String pValue = _properties.getProperty(pName);
        return parseInt(pName, pValue, defaultValue);
    }
350900
def value_or_default(self, value):
        '''  '''
        if value is None:
            if callable(self.default):
                return self.default()
            else:
                return self.default

        return value
1225645
function default_value() {
  start_pos = input.pointer();
  value = parse_balanced(/\[/, /\]/, /[^\[\]]*/);
  if (look(/\]/)) {
    return value;
  }
  else {
    input.setPointer(start_pos);
    return match(/[^\]]*/);
  }
}
1292864
def _parse_int(value, default=None):
    
    if value is None:
        return default
    try:
        return int(value)
    except ValueError:
        print "Couldn't cast value to `int`."
        return default
771847
public int getValueAsIntWithDefault(String keyIdField, int defaultVal) throws IOException {
        if(keyToValue.containsKey(keyIdField)) {
            return Integer.parseInt(getValue(keyIdField));
        }
        else return defaultVal;
    }
632944
function parseNumberArray( value ) {

		var array = value.split( ',' ).map( function ( val ) {

			return parseFloat( val );

		} );

		return array;

	}
651314
function parseValue(value) {
    if (['true', 'false'].includes(value)) {
        return value === 'true';
    }
    // is it float parsable?
    const parsed = parseFloat(value);
    if (!isNaN(parsed)) {
        return parsed;
    }
    return value;
}
332579
function () {

// Parse a number value.

            var number,
                string = '';

            if (ch === '-') {
                string = '-';
                next('-');
            }
            while (ch >= '0' && ch <= '9') {
                string += ch;
                next();
            }
            if (ch === '.') {
                string += '.';
                while (next() && ch >= '0' && ch <= '9') {
                    string += ch;
                }
            }
            if (ch === 'e' || ch === 'E') {
                string += ch;
                next();
                if (ch === '-' || ch === '+') {
                    string += ch;
                    next();
                }
                while (ch >= '0' && ch <= '9') {
                    string += ch;
                    next();
                }
            }

            number = +string;

            if (!isFinite(number)) {
                error("Bad number");
            } else {
                
                // means JS rounded or truncated number, too big
                if (number.toString() !== string) {
                    try {
                        return new BigNumber(string);
                    } catch (e) {
                        // if fails, fallback to default behavior
                    }
                }

                return number;
            }
        }