currency

Algorithm possible amounts (over)paid for a specific price, based on denominations

In a current project, people can order goods delivered to their door and choose 'pay on delivery' as a payment option. To make sure the delivery guy has enough change customers are asked to input the amount they will pay (e.g. delivery is 48,13, they will pay with 60,- (3*20,-)). Now, if it were up to me I'd make it a free field, but app...

split currency and amount from a string

I am importing a file which has amount with different currency signs £12.10 $26.13 €12.50 I need to import and convert this into single currency. I am splitting the string as follows $parts = split(' ', preg_replace("/([0-9])/", ' ${1}', $amount, 1)); Couldn't make preg_split work with PREG_SPLIT_DELIM_CAPTURE $parts = preg_split(...

Displaying currency in C#

I need to display data values in US currency format. Meaning 190.8 should display as $190.80. For some reason I cant figure out how to do this. Any advice? ...

USD Currency Formatting in Java

In java, how can I efficiently convert floats like 1234.56 and similar BigDecimals into Strings like $1,234.56 I'm looking for the following: String 12345.67 becomes String $12,345.67 Float and BigDecimal as well. Thanks. ...

javascript correctly rounding up to two decimals, impossible?

In php, we have number_format(). Passing it a value such as: number_format(3.00 * 0.175, 2); returns 0.53, which is what I would expect. However, in JavaScript using toFixed() var num = 3.00 * 0.175; num.toFixed(2); returns 0.52. Ok, so perhaps toFixed is not what I want... Maybe something like this... var num = 3.17 * 0.175; v...

How to correctly format text based on currency

Hello, In my application a calculation is performed which display the text to the GUI. The application multiplies a user given amount by a defined number (Say 0.85) to create a total (User types in 2, application works out 2 x 0.85). As the number that is displayed is that of a currency I am trying to correctly format the text to make ...

Multi-Currency Best Practice & Implementation

I'm finding it difficult to find any discussion on best practices for dealing with multiple currencies. Can anyone provide some insight or links to help? I understand there are a number of ways to do this - either transactionally where you store the value entered as is, or functionally where you convert to a base rate. In both cases the...

currency rates from yahoo finance limitations

Hello, I'm trying to write a script that would download currency rates from yahoo finance. The problem is ... i can't find any information on the limitations of this service. Especially i'm interested in how often i can query yahoo finance to access the quotes.csv file. Would yahoo kill my script if i executed it periodically every minu...

convert decimal to a string - in thousands with rounding

Hi, I need to convert a decimal to currency string so i did this: CultureInfo usa = new CultureInfo("en-US"); NumberFormatInfo nfi = usa.NumberFormat; nfi.CurrencyDecimalDigits = 0; myValueFormated = String.Format(nfi, "{0:C}", value); It removed decimal places, gave me a comma separato...

Storing currency values in SQLite3

I'm dealing with lots of different currencies in my application, and I want to know what the "best" way is to store them in an SQLite3 database. I'm leaning towards a fixed-point representation (i.e. store them as integers, where $3.59 gets stored as 359, ¥400 stored as 40000). Is this a good idea? What if my input data later changes an...

Currency Conversion using PHP

I'm looking for a way to convert any amount from one currency to another on a website. The user would enter something like '100' and select USD as the currency, and then chooses Australian or Canadian dollars as the currency to convert to. When he clicks the 'Convert' button, I'd like to convert that amount automatically, through some AP...

PHP > Zend Framework > Zend_Money

Hi I've used Zend_Money to format currency as follow $currency = new Zend_Currency(array('value' => $money, 'currency' => 'CAN', 'format' => 'fr')); // output -> 100,00 $ Which display normally on my local development system (wamp on windows) But when i put it...

Are currency formatting functions actually useful?

Many languages, such as .NET languages and Java come with a currency formatting facility built-in. What they do is format a number using a culture-specific number format and add the culture's currency symbol. The problem here is that the number format is strongly coupled to the currency symbol. In practice the number format should be th...

Algorithm to determine exchange rate

Given a data set of various currency pairs, how do I efficiently compute the implied fx rate for a pair not supplied in the data set? For example, say my database/table looks like this (this data is fudged): GBP x USD = 1.5 USD x GBP = 0.64 GBP x EUR = 1.19 AUD x USD = 1.1 Notice that (GBP,USD) != 1/(USD,GBP). I would expect the...

What's the proper way to show money in an UI in Java?

On the backend I'm storing money values in a Money class which wraps a BigDecimal and sets rounding to be always Half Even with scale 8. All basic operations work fine and behave as expected. But I need to show those values to the user with scale of 2, and that's bringing me rounding errors. For example, I have these values in the backe...

Convert basic script to Objective C (money formatting)

Hello, I've got this basic like script that I need to convert to objective c, it turns big units of money into shortened versions (ie: 1.2m, etc), I've got most of the conversion done, but the biggest problem I'm having is right at the end. The original basic code is: ; Basic Code Function ShortCash$(BigNumber) out$="" ; First, ...

Is there a way to format a variety of currencies on Python?

I've got a Python web server (mod_python, if that makes any difference) that I want to start formatting some currency. I've got two pieces of information when I format the currency - the value (as a number) and the currency (as the three-letter ISO 4217 code). I can also retrieve the country (or even city) that the currency is being fo...

Magento custom currency saving?

I'm trying to get some currency exchange rates in a seperate php file in magento and saving them: <?php // Initiate application $mageFilename = 'app/Mage.php'; require_once $mageFilename; Mage::app(); // Code to create my $rates array /** CODE **/ foreach ($rates as $currencyCode => $currencyRates) { Mage::getModel('directory/c...

How can i format decimal property to currency

I want to format the value in the getter and return a formated currency value. Is this possible or do i need to declare the property as a string and then use string.format. ...

Using NSNumberFormatter to get a decimal value from an international currency string

It seems that the NSNumberFormatter can't parse Euro (and probably other) currency strings into a numerical type. Can someone please prove me wrong. I'm attempting to use the following to get a numeric amount from a currency string: NSNumberFormatter *currencyFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [currencyFormatte...