This method implements the pattern of transforming a numeric value into
 another numeric value with the same units.
 It yields a number to a block to perform the operation and return a number
765976
def numeric_transformation(value)
      assert_type value, :Number, :value
      Sass::Script::Value::Number.new(
        yield(value.value), value.numerator_units, value.denominator_units)
    end
42617
def combine_numeric_values(self, other):
        
        if self.values is None:
            ret = IdValues()
        else:
            ret = sum([IdValues(
                {k: int(v) * int(other.values[key]) for k, v in value.items()})
                for key, value in self.values.items()])
        return ret
232476
private TypeSpec create(NumberData data, UnitData unitData, String className) {
    LocaleID id = data.id();

    // TODO: add descriptive javadoc to type
    TypeSpec.Builder type = TypeSpec.classBuilder(className)
        .superclass(NUMBER_FORMATTER_BASE)
        .addModifiers(Modifier.PUBLIC);
    
    // Build the constructor's code block
    String fmt = "super(\n";
    List<Object> args = new ArrayList<>();

    fmt += "$T.$L,\n";
    args.add(CLDR_LOCALE_IF);
    args.add(id.safe);

    fmt += "new _Params(),\n";

    fmt += "// decimal standard\n";
    fmt += "patterns($S, $S),\n";
    args.addAll(getPatterns(data.decimalFormatStandard));
    
    fmt += "// percent standard\n";
    fmt += "patterns($S, $S),\n";
    args.addAll(getPatterns(data.percentFormatStandard));

    fmt += "// currency standard\n";
    fmt += "patterns($S, $S),\n";
    args.addAll(getPatterns(data.currencyFormatStandard));
    
    fmt += "// currency accounting\n";
    fmt += "patterns($S, $S),\n";
    args.addAll(getPatterns(data.currencyFormatAccounting));

    fmt += "// units standard\n";
    fmt += "patterns($S, $S)\n";
    List<NumberPattern> unitPatterns = data.decimalFormatStandard.stream()
        .map(p -> {
          p = NUMBER_PARSER.parse(p.render());
          p.format().setMaximumFractionDigits(1);
          p.format().setMinimumFractionDigits(0);
          return p;
        }).collect(Collectors.toList());
    args.addAll(getPatterns(unitPatterns));
    
    fmt += ")";

    // Build the constructor.
    MethodSpec.Builder code = MethodSpec.constructorBuilder()
        .addModifiers(PUBLIC)
        .addStatement(fmt, args.toArray());
    type.addMethod(code.build());
    
    // Create a private instance of the NumberFormatterParams type
    addParams(type, id, data);

    addCompactPattern(type, "DECIMAL_SHORT", data.decimalFormatShort, false, data);
    addCompactPattern(type, "DECIMAL_LONG", data.decimalFormatLong, false, data);
    addCompactPattern(type, "CURRENCY_SHORT", data.currencyFormatShort, true, data);
    
    addUnitPattern(type, "UNITS_LONG", unitData.long_);
    addUnitPattern(type, "UNITS_NARROW", unitData.narrow);
    addUnitPattern(type, "UNITS_SHORT", unitData.short_);
    
    addCurrencyInfo(type, data);
    addUnitWrappers(type, data);
    
    return type.build();
  }
262660
private static Number asNumber(Object value) {
    Number num = null;
    if (value == null) {
      num = null;
    } else if (value instanceof Number) {
      num = (Number) value;
    } else if (value instanceof Boolean) {
      num = ((Boolean) value) ? 1 : 0;
    }
    return num;
  }
866339
def convert_to(other)
      return self if other.nil?

      case other
        when Unit
          return self if other == self
          target = other
        when String
          target = SIUnits::Unit.new(other.to_f)
        else
          raise ArgumentError, "Unknown target units"
      end
    end
985551
function unitConvert(obj, k) {
  if (objType(obj) === 'number') {
    return obj * 72 / 96 / k;
  } else {
    var newObj = {};
    for (var key in obj) {
      newObj[key] = obj[key] * 72 / 96 / k;
    }
    return newObj;
  }
}
809693
function transform( numQuantiles ) {
		/**
		* FUNCTION: transform( data )
		*	Defines the data transformation.
		*
		* @private
		* @param {number} data - numeric stream data
		* @returns {number} transformed data
		*/
		return function transform( data ) {
			// Convert a comma delimited string into an array:
			data = JSON.parse( '[' + data + ']' );

			// Compute the quantiles:
			return quantiles( data, numQuantiles );
		};
	}
1173736
def convert(self, value, fromunits, tounits):
        ''''''
        if fromunits == tounits:
            return value
        if (fromunits,tounits) in self.unitmap:
            return value * self.unitmap[(fromunits,tounits)]
        if (tounits,fromunits) in self.unitmap:
            return value / self.unitmap[(tounits,fromunits)]
        raise fgFDMError("unknown unit mapping (%s,%s)" % (fromunits, tounits))
390582
function convertFormatNumber (value, num) {
  // 序数
  if (num === 0) {
    return suji(value, '序数');
  }
  // 0埋め
  if (typeof value === 'number') {
    value = value + '';
    return value.length < num ? ('000000000' + value).slice(-num) : value;
  }
  // 切り捨て
  return num && num < value.length ? value.substring(0, num) : value;
}
460895
def unit_conversion(thing, units, length=False):
    """"""
    if 'n/a' == thing:
        return 'n/a'
    try:
        thing = round(thing * CONVERSION[units][0 + length], 2)
    except TypeError:
        thing = 'fubar'
    return thing, CONVERSION[units][2 + length]
723456
def _to_numeric(val):
    
    if isinstance(val, (int, float, datetime.datetime, datetime.timedelta)):
        return val
    return float(val)
1153217
private Number sum(Number a, Number b) {
    if (a instanceof Integer) {
      return Integer.valueOf(a.intValue() + b.intValue());
    }
    else if (a instanceof Float) {
      return new Float(a.floatValue() + b.floatValue());
    }
    else if (a instanceof Short) {
      return Short.valueOf((short)(a.shortValue() + b.shortValue()));
    }
    else if (a instanceof Byte) {
      return Byte.valueOf((byte)(a.byteValue() + b.byteValue()));
    }
    else if (a instanceof Long) {
      return Long.valueOf((a.longValue() + b.longValue()));
    }
    else {
      // should never happen
      throw new MetricsException("Invalid number type");
    }
            
  }
950707
def split_number_and_unit(s):
    
    if not s:
        raise ValueError('empty value')
    s = s.strip()
    pos = len(s)
    while pos and not s[pos-1].isdigit():
        pos -= 1
    number = int(s[:pos])
    unit = s[pos:].strip()
    return (number, unit)
617184
def range_to_numeric(ranges):
    
    values, units = zip(*(r.split() for r in ranges))
    # Detect common unit.
    unit = os.path.commonprefix([u[::-1] for u in units])

    # Strip unit to get just the SI prefix.
    prefixes = (u[:-len(unit)] for u in units)

    # Convert string value and scale with prefix.
    values = [float(v) * SI_PREFIX[p] for v, p in zip(values, prefixes)]
    return values
1119633
function normalizeNumber(val) {
  var bits = howManyBits(val);
  var bytes = howManyBytes(val);
  var value;
  if(bits <= 32) {
    value = val;
  } else {
    value = _(bytes).times(function(idx) {
      var result = val % 256;
      val = Math.floor(val / 256);
      return result;
    }).reverse();
  } 
  return {
    value: value,
    bits:  (bits % 8),
    bytes: Math.floor(bits / 8)
  };
}
715176
def convert(quantity)
      if Quantity===quantity
        assert_same_dimension(quantity.unit)
        v = quantity.unit.convert_value_to_base_unit(quantity.value)
        convert_value_from_base_unit(v)
      else
        quantity / to_numeric
      end
    end
1198121
private BigRational multiply(BigDecimal value) {
		BigDecimal n = numerator.multiply(value);
		BigDecimal d = denominator;
		return of(n, d);
	}