Convert a value to satoshis. units can be any fiat currency.
        By default the unit is satoshi.
199387
def from_unit_to_satoshi(self, value, unit='satoshi'):
        
        if not unit or unit == 'satoshi':
            return value
        if unit == 'bitcoin' or unit == 'btc':
            return value * 1e8

        # assume fiat currency that we can convert
        convert = get_current_price(self.crypto, unit)
        return int(value / convert * 1e8)
980221
def to_si(self, values, from_unit):
        """"""
        if from_unit in self.si_units:
            return values, from_unit
        elif from_unit == 'ton':
            return self.to_unit(values, 'tonne', from_unit), 'tonne'
        else:
            return self.to_unit(values, 'kg', from_unit), 'kg'
169055
function convert(currency) {
    // Store the current currency.
    var oldCurrency = Currency.currentCurrency;

    // Call convertAll with all possible formats. Currency.currentCurrency will be set as a side effect.
    Currency.convertAll(Currency.currentCurrency, currency, '[data-convert="money"]', 'money_format');
    Currency.convertAll(Currency.currentCurrency, currency, '[data-convert="money_with_currency"]', 'money_with_currency_format');
    Currency.convertAll(Currency.currentCurrency, currency, '[data-convert="money_without_currency"]', 'money_without_currency_format');

    // Save the chosen currency in a cookie.
    Currency.cookie.write(currency);

    // If there was a change in currency, fire the currency changed event.
    if(oldCurrency != currency) {
      $(document).trigger('currency.changed', [oldCurrency, currency]);
    }
  }
604514
def _convert_units(devices):
    '''
    
    '''
    if devices:
        for device in devices:
            if 'unit' in device and 'size' in device:
                device.update(
                    salt.utils.vmware.convert_to_kb(device['unit'], device['size']))
    else:
        return False
    return True
1340905
def to_btc(ccy, value, api_code=None):
    
    
    res = 'tobtc?currency={0}&value={1}'.format(ccy, value)
    if api_code is not None:
        res += '&api_code=' + api_code
    return float(util.call_api(res))
717207
def to_unit(C, val, unit=None):
        """"""
        md = re.match(r'^(?P<num>[\d\.]+)(?P<unit>.*)$', val)
        if md is not None:
            un = float(md.group('num')) * CSS.units[md.group('unit')]
            if unit is not None:
                return un.asUnit(unit)
            else:
                return un
846698
def validate_units(self, value):
        """"""
        self.validate_quantity(value)
        self.units_type = inspect.stack()[1][3].split('_')[-1]
        assert self.units_type, ("`validate_units` should not be called "
                                 "directly. It should be called by a "
                                 "_validate_type_* methods that sets "
                                 "`units_type`")
        units = getattr(pq, self.units_map[self.units_type])
        if not value.simplified.units == units:
            self._error('%s' % value,
                        "Must have dimensions of %s." % self.units_type)
        return True
1107850
def __set_unit(self, value):
        '''
        
        '''
        if value in UNITS:
            value = value.upper()

        self.__unit = value
745142
private List<Object> convertType(DataType type, byte[] data)
   {
      List<Object> result = new ArrayList<Object>();
      int index = 0;

      while (index < data.length)
      {
         switch (type)
         {
            case STRING:
            {
               String value = MPPUtility.getUnicodeString(data, index);
               result.add(value);
               index += ((value.length() + 1) * 2);
               break;
            }

            case CURRENCY:
            {
               Double value = Double.valueOf(MPPUtility.getDouble(data, index) / 100);
               result.add(value);
               index += 8;
               break;
            }

            case NUMERIC:
            {
               Double value = Double.valueOf(MPPUtility.getDouble(data, index));
               result.add(value);
               index += 8;
               break;
            }

            case DATE:
            {
               Date value = MPPUtility.getTimestamp(data, index);
               result.add(value);
               index += 4;
               break;

            }

            case DURATION:
            {
               TimeUnit units = MPPUtility.getDurationTimeUnits(MPPUtility.getShort(data, index + 4), m_properties.getDefaultDurationUnits());
               Duration value = MPPUtility.getAdjustedDuration(m_properties, MPPUtility.getInt(data, index), units);
               result.add(value);
               index += 6;
               break;
            }

            case BOOLEAN:
            {
               Boolean value = Boolean.valueOf(MPPUtility.getShort(data, index) == 1);
               result.add(value);
               index += 2;
               break;
            }

            default:
            {
               index = data.length;
               break;
            }
         }
      }

      return result;
   }
1092303
public Fiat parseFiat(String currencyCode, String str) throws NumberFormatException {
        return Fiat.valueOf(currencyCode, parseValue(str, Fiat.SMALLEST_UNIT_EXPONENT));
    }
513768
def convert(self, money, to_currency, date=None):
        
        if str(money.currency) == str(to_currency):
            return copy.copy(money)
        return Money(
            amount=money.amount
            * self.rate(money.currency, to_currency, date or datetime.date.today()),
            currency=to_currency,
        )
1224087
def to_si
      if @unit.is_compound_unit?
        Quantity.new(@value,@unit).convert_compound_unit_to_si!
      elsif @unit.is_dimensionless?
        return self.clone
      elsif @value.nil?
        return Quantity.new(nil, @unit.si_unit)
      else
        self.to(@unit.si_unit)
      end
    end
502115
def convert(amount, from_code, to_code, decimals=2, qs=None):
    """"""
    if from_code == to_code:
        return amount

    if qs is None:
        qs = get_active_currencies_qs()

    from_, to = qs.get(code=from_code), qs.get(code=to_code)

    amount = D(amount) * (to.factor / from_.factor)
    return price_rounding(amount, decimals=decimals)
741491
def convert_value(self, value):
        
        if isinstance(value, str):
            assert value.startswith(self.symbol), "Currency does not start with " + self.symbol
            value = value.lstrip(self.symbol)
        return super().convert_value(value)
366311
public static Money zero(CurrencyUnit currency) {
        MoneyUtils.checkNotNull(currency, "Currency must not be null");
        BigDecimal bd = BigDecimal.valueOf(0, currency.getDecimalPlaces());
        return new Money(BigMoney.of(currency, bd));
    }
1248086
def to(self, currency):
        """"""
        if currency == self._currency:
            return self
        rate = xrates.quotation(self._currency, currency)
        if rate is None:
            raise ExchangeRateNotFound(xrates.backend_name,
                                         self._currency, currency)
        amount = self._amount * rate
        return self.__class__(amount, currency)
1227322
def currency(s=''):
    ''
    if isinstance(s, str):
        s = ''.join(ch for ch in s if ch in floatchars)
    return float(s) if s else TypedWrapper(float, None)