nicely formats the amount and currency
516423
def format_currency(amount, currency)
      
      currency = currency.upcase()
      # assuming that all currencies are split into 100 parts is probably wrong
      # on an i18n scale but it works for USD, EUR and LBP
      # TODO fix this maybe?
      amount = amount / 100.0
      options = {
        # use comma for euro 
        separator: currency == 'EUR' ? ',' : '.', 
        delimiter: currency == 'EUR' ? '.' : ',',
        format: currency == 'EUR' ? '%n %u' : '%u%n',
      }
      case currency
      when 'EUR'
        options[:unit] = '€' 
      when 'LBP'
        options[:unit] = '£'
      when 'USD'
        options[:unit] = '$'
      else
        options[:unit] = currency
      end
      return number_to_currency(amount, options)
    end
38468
public function NiceDecimalPoint()
    {
        $currencySymbol = Currency::config()->get('currency_symbol');
        $decimalPoint = Currency::config()->get('decimal_point');
        $thousandSeparator = Currency::config()->get('thousand_seperator');
        $val = $currencySymbol . number_format(abs($this->owner->value), 2, $decimalPoint, $thousandSeparator);
        if ((double)$this->owner->value === (double)0) {
            return _t('CurrencyExtension.FREE', 'Free');
        } elseif ((double)$this->owner->value < 0) {
            return "($val)";
        } else {
            return $val;
        }
    }
829604
static String formatPriceString(double amount, @NonNull Currency currency) {
        double majorUnitAmount = amount / Math.pow(10, currency.getDefaultFractionDigits());
        NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();
        try {
            DecimalFormatSymbols decimalFormatSymbols = ((java.text.DecimalFormat) currencyFormat)
                    .getDecimalFormatSymbols();
            decimalFormatSymbols.setCurrencySymbol(currency.getSymbol(Locale.getDefault()));
            ((java.text.DecimalFormat) currencyFormat)
                    .setDecimalFormatSymbols(decimalFormatSymbols);
            return currencyFormat.format(majorUnitAmount);
        } catch (ClassCastException e) {
            return currencyFormat.format(majorUnitAmount);
        }
    }
438568
def as_currency(self, currency='USD', locale=LOCALE_OBJ, *args, **kwargs):
        
        f = Formatter(
            as_currency(currency=currency, locale=locale),
            args,
            kwargs
        )
        return self._add_formatter(f)
785375
public function formatCurrency($value, $currency, $precision=2)
    {
        $newValue = trim($value, " \0\x0B$currency");
        if (!is_numeric($newValue)) {
            return $value;
        }

        $pattern = $this->getPattern($value, 'Intl_NumberFormatCurrency');

        if ($newValue == round($newValue)) {
            // if no fraction digits available, don't show any
            $value = $this->formatNumberWithPattern($pattern, $newValue, 0, 0);
        } else {
            // show given count of fraction digits otherwise
            $value = $this->formatNumberWithPattern($pattern, $newValue, $precision, $precision);
        }

        return str_replace('¤', $currency, $value);
    }
358833
public function format($amount, $locale = 'en')
    {
        switch ($locale)
        {
            case 'de':
            case 'tr':
            case 'pt':
            case 'it':
            case 'nl':
                $amount = number_format($amount, 2, ',', '.');
                break;

            case 'fr':
            case 'ru':
                $amount = number_format($amount, 2, ',', ' ');
                break;

            case 'en':
                $amount = number_format($amount, 2, '.', ',');
                break;
        }

        return $amount;
    }
811632
public function format()
    {
        $format = $this->amount();

        if ($this->currency->getSymbol() === null) {
            $format .= ' '.$this->currency->getCode();
        } elseif ($this->currency->getSymbolPlacement() == 'before') {
            $format = $this->currency->getSymbol().$format;
        } else {
            $format .= $this->currency->getSymbol();
        }

        return $format;
    }
781262
def formatCurrency( value, options = nil )
      value ||= "0.00"
      if !value.include?( '.' )
         value << ".00"
      end
      
      currencySymbol = currencyFormat = nil
      if options
         currencySymbol = options["currencySymbol"]
         currencyFormat = options["currencyFormat"]
      end
      
      if currencySymbol
         if currencyFormat
            if currencyFormat == "0"
               value = "#{currencySymbol}#{value}"
            elsif currencyFormat == "1"
               if value.include?("-")
                  value.gsub!("-","-#{currencySymbol}")
               elsif value.include?("+")
                  value.gsub!("+","+#{currencySymbol}")
               else   
                  value = "#{currencySymbol}#{value}"
               end
            elsif currencyFormat == "2"
               value = "#{value}#{currencySymbol}"
            end
         else
            value = "#{currencySymbol}#{value}"
         end
      end
      
      value
   end
884262
def price_value_renderer(value, currency=None, **options):
    """"""
    if not currency:
        currency = getattr(settings, 'CURRENCY', 'USD')
    return format_currency(value, currency, locale=utils.get_current_locale())
338676
public static String formatCurrency(ITemplate template, Object data, String currencyCode) {
        return formatCurrency(template, data, currencyCode, null);
    }
38972
public function formatAmount($amount, $currency = null)
    {
        return str_replace('.00', '', $this->moneyHelper->formatAmount($amount, $currency));
    }
1253464
def truncate_to(value: Decimal, currency: str) -> Decimal:
    """"""
    decimal_places = DECIMALS.get(currency.upper(), 2)
    return truncate(value, decimal_places)
986966
public static void format(
      BigDecimal n,
      DigitBuffer buf,
      NumberFormatterParams params,
      boolean currencyMode,
      boolean grouping,
      int minIntDigits,
      int primaryGroupingSize,
      int secondaryGroupingSize) {

    // Setup integer digit grouping.
    if (secondaryGroupingSize <= 0) {
      secondaryGroupingSize = primaryGroupingSize;
    }

    // Check if we need to perform digit grouping.
    int groupSize = primaryGroupingSize;
    boolean shouldGroup = false;

    // Output as many integer digits as are available, unless minIntDigits == 0
    // and our value is < 1.
    long intDigits = integerDigits(n);
    if (minIntDigits == 0 && n.compareTo(BigDecimal.ONE) == -1) {
      intDigits = 0;
    } else {
      intDigits = Math.max(intDigits, minIntDigits);
    }

    if (grouping) {
      if (primaryGroupingSize > 0) {
        shouldGroup = intDigits >= (params.minimumGroupingDigits + primaryGroupingSize);
      }
    }

    // Select the decimal and grouping characters.
    String decimal = currencyMode ? params.currencyDecimal : params.decimal;
    String group = currencyMode ? params.currencyGroup : params.group;

    // Keep a pointer to the end of the buffer, since we render the formatted number
    // in reverse to be a bit more compact.
    int bufferStart = buf.length();

    // We only emit the absolute value of the number, since the indication of
    // negative numbers is pattern and locale-specific.
    if (n.signum() == -1) {
      n = n.negate();
    }

    // Translate the standard decimal representation into the localized form.
    // At this point the number of integer and decimal digits is set, all we're
    // doing is outputting the correct decimal symbol and grouping symbols.

    String s = n.toPlainString();
    int end = s.length() - 1;

    // Emit decimal digits and decimal point.
    int idx = s.lastIndexOf('.');
    if (idx != -1) {
      while (end > idx) {
        buf.append(s.charAt(end));
        end--;
      }

      end--;
      buf.append(decimal);
    }

    // Emit integer part with optional grouping
    int emitted = 0;
    while (intDigits > 0 && end >= 0) {
      // Emit grouping digits.
      if (shouldGroup) {
        boolean emit = emitted > 0 && emitted % groupSize == 0;
        if (emit) {
          // Append a grouping character and switch to the secondary grouping size
          buf.append(group);
          emitted -= groupSize;
          groupSize = secondaryGroupingSize;
        }
      }
      buf.append(s.charAt(end));
      end--;
      emitted++;
      intDigits--;
    }

    // Emit zeroes to pad integer part with optional grouping
    if (intDigits > 0) {
      for (int i = 0; i < intDigits; i++) {
        // Emit grouping digits.
        if (shouldGroup) {
          boolean emit = emitted > 0 && emitted % groupSize == 0;
          if (emit) {
            // Append a grouping character and switch to the secondary grouping size
            buf.append(group);
            emitted -= groupSize;
            groupSize = secondaryGroupingSize;
          }
        }
        buf.append('0');
        emitted++;
      }
    }

    buf.reverse(bufferStart);
  }
513353
function getCurrencySymbol(code, format, locale) {
    if (locale === void 0) { locale = 'en'; }
    var currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || [];
    var symbolNarrow = currency[1 /* SymbolNarrow */];
    if (format === 'narrow' && typeof symbolNarrow === 'string') {
        return symbolNarrow;
    }
    return currency[0 /* Symbol */] || code;
}
1090627
function formatSingle(format, val) {
        var floatRegex = /f$/,
          decRegex = /\.([0-9])/,
          lang = defaultOptions.lang,
          decimals;

        if (floatRegex.test(format)) { // float
            decimals = format.match(decRegex);
            decimals = decimals ? decimals[1] : -1;
            if (val !== null) {
                val = numberFormat(
                  val,
                  decimals,
                  lang.decimalPoint,
                  format.indexOf(',') > -1 ? lang.thousandsSep : ''
                );
            }
        } else {
            val = dateFormat(format, val);
        }
        return val;
    }
599527
def currency_format(cents):
    
    try:
        cents = int(cents)
    except ValueError:
        return cents

    negative = (cents < 0)
    if negative:
        cents = -1 * cents

    if cents < 100:
        dollars = 0
    else:
        dollars = cents / 100
        cents = cents % 100

    centstr = str(cents)
    if len(centstr) < 2:
        centstr = '0' + centstr

    if negative:
        return "- $%s.%s" % (intcomma(dollars), centstr)
    return "$%s.%s" % (intcomma(dollars), centstr)
1073128
public function format($value)
    {
        $formatter = new NumberFormatter($this->locale(), NumberFormatter::CURRENCY);

        $code = $this->code($value);
        $divisor = $this->divisor($code);
        $amount = $this->convert($value, $divisor);

        return $formatter->formatCurrency($amount, $code);
    }