Questions tagged [currency]

Currency is a medium of exchange of value, usually referring to government issued denominations.

The Currency tag is relevant to any topic that involves the handling of currency, including accurate calculation, rounding schemes, best practices and display formatting. It is also applicable to discussions of how specific languages or libraries handle currency.

http://en.wikipedia.org/wiki/Currency

2964 questions
66
votes
19 answers

What to do with Java BigDecimal performance?

I write currency trading applications for living, so I have to work with monetary values (it's a shame that Java still doesn't have decimal float type and has nothing to support arbitrary-precision monetary calculations). "Use BigDecimal!" — you…
Alexander Temerev
  • 661
  • 1
  • 6
  • 5
66
votes
10 answers

Django: How should I store a money value?

I'm running into a paradigm problem here. I don't know whether I should store money as a Decimal(), or if I should store it as a string and convert it to a decimal myself. My reasoning is this: PayPal requires 2 decimal places, so if I have a…
orokusaki
  • 55,146
  • 59
  • 179
  • 257
66
votes
5 answers

to_d to always return 2 decimals places in ruby

I'm dealing with currencies and I want to round down the number to 2 decimal places. Even if the number is 500.0, I would like it to be 500.00 to be consistent. When I do "500.00".to_d it converts it to 500.0. Whats a good way of changing this…
ed1t
  • 8,719
  • 17
  • 67
  • 110
65
votes
7 answers

storing money amounts in mysql

I want to store 3.50 into a mysql table. I have a float that I store it in, but it stores as 3.5, not 3.50. How can I get it to have the trailing zero?
David
  • 16,246
  • 34
  • 103
  • 162
61
votes
8 answers

Print Currency Number Format in PHP

I have some price values to display in my page. I am writing a function which takes the float price and returns the formatted currency val with currency code too.. For example, fnPrice(1001.01) should print $ 1,000.01
KoolKabin
  • 17,157
  • 35
  • 107
  • 145
61
votes
9 answers

3 Digit currency code to currency symbol

In C# is it possible to get a currency symbol, like '£', from the 3 character currency code, in this case 'GBP'? Is this possible either in SQL Server or in C#?
Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
58
votes
8 answers

Get the currency from current culture?

Is there a way to get current information dynamically from the apps culture settings? Basically if the user has set the culture to US I want to know the currency is dollars, or if they have it set to UK I want to pound sterling etc... etc.. This is…
YodasMyDad
  • 9,248
  • 24
  • 76
  • 121
56
votes
6 answers

Should I use NSDecimalNumber to deal with money?

As I started coding my first app I used NSNumber for money values without thinking twice. Then I thought that maybe c types were enough to deal with my values. Yet, I was advised in the iPhone SDK forum to use NSDecimalNumber, because of its…
nutsmuggler
  • 1,707
  • 5
  • 21
  • 27
56
votes
9 answers

Format a double value like currency but without the currency sign (C#)

I feed a textbox a string value showing me a balance that need to be formatted like this: ###,###,###,##0.00 I could use the value.ToString("c"), but this would put the currency sign in front of it. Any idea how I would manipulate the string before…
Houman
  • 64,245
  • 87
  • 278
  • 460
55
votes
7 answers

Find locale currency for iphone programmatically

I want to find out the currency locale on user's iphone programmatically. That means, if user is in US Store, the currency locale should be USD, for Australia, it should be AUD. My purpose of this task is to try to convert the item price listed on…
vodkhang
  • 18,639
  • 11
  • 76
  • 110
54
votes
9 answers

Java double comparison epsilon

I wrote a class that tests for equality, less than, and greater than with two doubles in Java. My general case is comparing price that can have an accuracy of a half cent. 59.005 compared to 59.395. Is the epsilon I chose adequate for those…
rich
54
votes
9 answers

Get currency symbol in PHP

Let's start with simple piece of code to format money with NumberFormatter: $formatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY); echo $formatter->formatCurrency(123456789, 'JPY'); This prints: ¥123,456,789. This is ok if you want…
umpirsky
  • 9,902
  • 13
  • 71
  • 96
53
votes
4 answers

Format a number with leading sign

How do I format in Java a number with its leading sign? Negative numbers are correctly displayed with leading -, but obviously positive numbers are not displayed with +. How to do that in Java? My current currency format string is…
usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305
50
votes
6 answers

Get the currency format for a country that does not have a Locale constant

I want to get the currency format of India, so I need a Locale object for India. But there exists only few a countries that have a Locale constant (a static final Locale), and India is not one of them. To get the currency symbols for the US and UK,…
Venkat
  • 20,802
  • 26
  • 75
  • 84
48
votes
8 answers

Formatting Currencies in Foreign Locales in Java

I'm doing my best to find a way to format foreign currencies across various locales which are not default for that currency, using Java. I've found java.util.Currency, which can represent the proper symbol to use for various locales. That is, for…
JPittard
  • 645
  • 1
  • 5
  • 6