Calculate and return the numerical type and the scale to
apply to the float values given in order to minimize the error.
482927
function getFloatScale( values, min, max, error ) {
	var mid = (min + max) / 2, range = mid - min,
		norm_8 = (range / INT8_MAX),
		norm_16 = (range / INT16_MAX),
		ok_8 = true, ok_16 = true,
		er_8 = 0, er_16 = 0,
		v, uv, er;

	// For the values given, check if 8-bit or 16-bit
	// scaling brings smaller error value
	for (var i=0, l=values.length; i<l; ++i) {

		// Test 8-bit scaling
		if (ok_8) {
			v = Math.round((values[i] - mid) / norm_8);
			uv = v * norm_8 + mid;
			er = (uv-v)/v;
			if (er > er_8) er_8 = er;
			if (er >= error) {
				ok_8 = false;
			}
		}

		// Test 16-bit scaling
		if (ok_16) {
			v = Math.round((values[i] - mid) / norm_16);
			uv = v * norm_16 + mid;
			er = (uv-v)/v;
			if (er > er_16) er_16 = er;
			if (er >= error) {
				ok_16 = false;
			}
		}

		if (!ok_8 && !ok_16)
			return [ 0, NUMTYPE.UNKNOWN ];
	}

	// Pick most appropriate normalization factor
	if (ok_8 && ok_16) {
		if (er_8 < er_16) {
			return [ norm_8, NUMTYPE.INT8 ];
		} else {
			return [ norm_16, NUMTYPE.INT16 ];
		}
	} else if (ok_8) {
		return [ norm_8, NUMTYPE.INT8 ];
	} else if (ok_16) {
		return [ norm_16, NUMTYPE.INT16 ];
	} else {
		return [ 0, NUMTYPE.UNKNOWN ];
	}

}
210891
def _validate_type_scalar(self, value):
        
        if isinstance(
            value, _int_types + (_str_type, float, date, datetime, bool)
        ):
            return True
182974
def _set_types(self):
        """"""
        # If we given something that is not an int or a float we raise
        # a RuntimeError as we do not want to have to guess if the given
        # input should be interpreted as an int or a float, for example the
        # interpretation of the string "1" vs the interpretation of the string
        # "1.0".
        for c in (self.x, self.y):
            if not ( isinstance(c, int) or isinstance(c, float) ):
                raise(RuntimeError('x, y coords should be int or float'))

        if isinstance(self.x, int) and isinstance(self.y, int):
            self._dtype = "int"
        else:
            # At least one value is a float so promote both to float.
            self.x = float(self.x)
            self.y = float(self.y)
            self._dtype = "float"
593045
def _cast_to_type(self, value):
        
        try:
            return float(value)
        except (ValueError, TypeError):
            self.fail('invalid', value=value)
525597
def validate(self):
        
        super(FloatFilter, self).validate()

        try:
            self._value = float(self._value)
        except (ValueError, TypeError), exc:
            raise FilterError("Bad numerical value %r in %r (%s)" % (self._value, self._condition, exc))
719229
def fix_float_precision(float)
      decimals = float.to_f.to_s[/\d+\z/]
      fixed_decimals = decimals.sub(/(\d)\1{5,}\d{,2}\z/, '')

      decimals == fixed_decimals ? float : float.round(fixed_decimals.size)
    end
178538
def normalize(x):
    ''''''
    x = x.astype(float)
    x -= x.mean()
    return x / float(x.std())
945938
private void calcAxisFoldTypes() {
		axisTypes = new int[multiplicity];

		for (int i=0;i<this.transformations.size();i++){

			axisTypes[i] = getRotAxisType(transformations.get(i));

		}
	}
430581
def try_number(value):
    

    for cast_function in [int, float]:
        try:
            return cast_function(value)
        except ValueError:
            pass

    raise ValueError("Unable to use value as int or float: {0!r}"
                     .format(value))
828701
def _float_values(self, shape):
        
        return self.state.uniform(low=0.0, high=100.0, size=shape)
514217
def validate_float(cls, value):
        
        if not isinstance(value, (int, float)):
            raise TypeError(
                "value must be a number, got %s" % type(value)
            )
235013
def normalize(value, default=None, type=None, raise_exception=False):
    
    NUMBER_RE = re.compile('^[-+]?(([0-9]+\.?[0-9]*)|([0-9]*\.?[0-9]+))$')
    if type is None and default is None:
        type = unicode_type
    elif type is None:
        type = type_(default)
    if type in str_types:
        if value is not None:
            if isinstance(value, unicode_type):
                return value
            elif py3 and isinstance(value, bytes_type):
                return value.decode('utf-8')
            return unicode_type(value)
        if default is None:
            if raise_exception:
                raise ValidationError('invalid string')
            else:
                return unicode_type()
    elif type in (bool, 'bool', 'boolean'):
        if value is not None:
            value = value.lower().strip()
            if value in ('1', 'true', 'yes', 'on'):
                return True
            elif value in ('0', 'false', 'no', 'off'):
                return False
        if default is None:
            if raise_exception:
                raise ValidationError('invalid boolean')
            else:
                return False
    elif type in (numbers.Number, 'number'):
        if value is not None:
            if value.isdigit():
                return int(value)
            elif NUMBER_RE.match(value):
                return eval(value)
        if default is None:
            if raise_exception:
                raise ValidationError('invalid number')
            else:
                return 0
    elif type in (int, 'int', 'integer'):
        try:
            return int(value)
        except Exception:
            if isinstance(value, basestring_type) and NUMBER_RE.match(value):
                return int(eval(value))
            if default is None:
                if raise_exception:
                    raise ValidationError('invalid number')
                else:
                    return 0
    elif type in (float, 'float'):
        if value is not None and NUMBER_RE.match(value):
            return float(value)
        if default is None:
            if raise_exception:
                raise ValidationError('invalid number')
            else:
                return 0.0
    return default
267470
private Double scale(Double value, Double min, Double max) {
        if(min.equals(max)) {
            if(value>max) {
                return 1.0;
            }
            else if(value==max && value!=0.0) {
                return 1.0;
            }
            else {
                return 0.0;
            }
        }
        else {
            return (value-min)/(max-min);
        }
    }
1123491
def _get_precision_scale(self, number):
        
        try:
            decimal_num = Decimal(number)
        except InvalidOperation:
            raise Invalid(self.msg or 'Value must be a number enclosed with string')

        return (len(decimal_num.as_tuple().digits), -(decimal_num.as_tuple().exponent), decimal_num)
1269238
def floating_point(
        element_name,  # type: Text
        attribute=None,  # type: Optional[Text]
        required=True,  # type: bool
        alias=None,  # type: Optional[Text]
        default=0.0,  # type: Optional[float]
        omit_empty=False,  # type: bool
        hooks=None  # type: Optional[Hooks]
):
    # type: (...) -> Processor
    
    value_parser = _number_parser(float)
    return _PrimitiveValue(
        element_name,
        value_parser,
        attribute,
        required,
        alias,
        default,
        omit_empty,
        hooks
    )
975564
function NumberType(typeSpec) {
  // Default to integer values
  this._allowFloat = !!typeSpec.allowFloat;

  if (typeSpec) {
    this._min = typeSpec.min;
    this._max = typeSpec.max;
    this._step = typeSpec.step || 1;

    if (!this._allowFloat &&
        (this._isFloat(this._min) ||
         this._isFloat(this._max) ||
         this._isFloat(this._step))) {
      throw new Error('allowFloat is false, but non-integer values given in type spec');
    }
  }
  else {
    this._step = 1;
  }
}
1167977
function num(type, value) {
  var val;
  if(type === NUMERIC.INTEGER) {
    val = utils.strtoint(value);
    if(isNaN(val)) throw IntegerRange;
  }else{
    val = utils.strtofloat(value);
    if(isNaN(val)) throw InvalidFloat;
  }
  return val;
}