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

2742 questions
79
votes
7 answers

How can I correctly format currency using jquery?

I do not need a mask, but I need something that will format currency(in all browsers) and not allow for any letters or special char's to be typed. Thanks for the help Example: Valid: $50.00 $1,000.53 Not Valid: $w45.00 $34.3r6
ninjasense
  • 13,382
  • 17
  • 71
  • 91
75
votes
24 answers

Use Float or Decimal for Accounting Application Dollar Amount?

We are rewriting our legacy Accounting System in VB.NET and SQL Server. We brought in a new team of .NET/ SQL Programmers to do the rewrite. Most of the system is already completed with the Dollar amounts using Floats. The legacy system language, I…
Gerhard Weiss
  • 8,423
  • 14
  • 60
  • 66
74
votes
8 answers

How can I format decimal property to currency?

I want to format a decimal value as a currency value. How can I do this?
WingMan20-10
  • 2,894
  • 8
  • 28
  • 41
72
votes
9 answers

Using BigDecimal to work with currencies

I was trying to make my own class for currencies using longs, but apparently I should use BigDecimal instead. Could someone help me get started? What would be the best way to use BigDecimals for dollar currencies, like making it at least but no more…
mk12
  • 24,644
  • 29
  • 92
  • 132
71
votes
8 answers

Is a double really unsuitable for money?

I always tell in c# a variable of type double is not suitable for money. All weird things could happen. But I can't seem to create an example to demonstrate some of these issues. Can anyone provide such an example? (edit; this post was originally…
doekman
  • 17,528
  • 19
  • 61
  • 80
70
votes
4 answers

Formatting money in twig templates

Are there any filters or something like that in twig template engine to format money or numbers?
umpirsky
  • 9,358
  • 12
  • 65
  • 92
66
votes
12 answers

Format currency without currency symbol

I am using NumberFormat.getCurrencyInstance(myLocale) to get a custom currency format for a locale given by me. However, this always includes the currency symbol which I don't want, I just want the proper currency number format for my given locale…
anderswelt
  • 1,322
  • 1
  • 9
  • 23
66
votes
12 answers

What is "The Best" U.S. Currency RegEx?

A quick search for currency regex brings up a lot of results. The problem I have in choosing one is that regex is difficult to verify without testing all the edge cases. Does anyone have a regex for U.S. currency that has been thoroughly tested? My…
Robert Claypool
  • 4,083
  • 9
  • 47
  • 59
66
votes
7 answers

How do I format a number to a dollar amount in PHP

How do you convert a number to a string showing dollars and cents? eg: 123.45 => '$123.45' 123.456 => '$123.46' 123 => '$123.00' .13 => '$0.13' .1 => '$0.10' 0 => '$0.00'
nickf
  • 499,078
  • 194
  • 614
  • 709
65
votes
5 answers

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…
Mr Shoubs
  • 12,813
  • 15
  • 63
  • 103
65
votes
9 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
  • 48,267
  • 47
  • 159
  • 244
65
votes
19 answers

Best way to store currency values in C++

I know that a float isn't appropriate to store currency values because of rounding errors. Is there a standard way to represent money in C++? I've looked in the boost library and found nothing about it. In java, it seems that BigInteger is the way…
Javier Ramos
64
votes
6 answers

How do I format a double to currency rounded to the nearest dollar?

Right now I have double numba = 5212.6312 String.Format("{0:C}", Convert.ToInt32(numba) ) This will give me $5,213.00 but I don't want the ".00". I know I can just drop the last three characters of the string every time to achieve the effect,…
spilliton
  • 3,631
  • 4
  • 33
  • 35
64
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
  • 14,182
  • 34
  • 96
  • 150
61
votes
20 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
  • 611
  • 1
  • 6
  • 5