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
2446
votes
67 answers

How to format numbers as currency strings

I would like to format a price in JavaScript. I'd like a function which takes a float as an argument and returns a string formatted like this: "$ 2,500.00" How can I do this?
Daniel Magliola
  • 30,898
  • 61
  • 164
  • 243
1203
votes
16 answers

Why not use Double or Float to represent currency?

I've always been told never to represent money with double or float types, and this time I pose the question to you: why? I'm sure there is a very good reason, I simply do not know what it is.
Fran Fitzpatrick
  • 17,902
  • 15
  • 33
  • 34
997
votes
7 answers

decimal vs double! - Which one should I use and when?

I keep seeing people using doubles in C#. I know I read somewhere that doubles sometimes lose precision. My question is when should a use a double and when should I use a decimal type? Which type is suitable for money computations? (ie. greater…
Soni Ali
  • 18,464
  • 16
  • 44
  • 53
508
votes
9 answers

What is the best data type to use for money in C#?

What is the best data type to use for money in C#?
NotDan
  • 31,709
  • 36
  • 116
  • 156
353
votes
14 answers

Best data type to store money values in MySQL

I want to store many records in a MySQL database. All of them contains money values. But I don't know how many digits will be inserted for each one. Which data type do I have to use for this purpose? VARCHAR or INT (or other numeric data types)?
Mohammad Saberi
  • 12,864
  • 27
  • 75
  • 127
348
votes
13 answers

What is the best method of handling currency/money?

I'm working on a very basic shopping cart system. I have a table items that has a column price of type integer. I'm having trouble displaying the price value in my views for prices that include both Euros and cents. Am I missing something obvious…
Barry Gallagher
  • 6,156
  • 4
  • 26
  • 30
230
votes
11 answers

What data type to use for money in Java?

What data type should you use for money in Java?
questborn
  • 2,735
  • 2
  • 16
  • 17
206
votes
10 answers

Storing money in a decimal column - what precision and scale?

I'm using a decimal column to store money values on a database, and today I was wondering what precision and scale to use. Since supposedly char columns of a fixed width are more efficient, I was thinking the same could be true for decimal columns.…
Ivan
  • 97,549
  • 17
  • 50
  • 58
204
votes
14 answers

Currency formatting in Python

I am looking to format a number like 188518982.18 to £188,518,982.18 using Python. How can I do this?
RailsSon
  • 19,897
  • 31
  • 82
  • 105
136
votes
5 answers

Cast a Double Variable to Decimal

How does one cast a double to decimal which is used when doing currency development. Where does the M go? decimal dtot = (decimal)(doubleTotal);
flo
  • 1,471
  • 2
  • 12
  • 13
129
votes
17 answers

HTML text input field with currency symbol

I would like to have a text input field containing the "$" sign in the very beginning, and no matter what editing occurs to the field, for the sign to be persistent. I would be good if only numbers were accepted for input, but that's just a fancy…
User3419
  • 1,716
  • 2
  • 14
  • 16
114
votes
15 answers

Programmatically access currency exchange rates

I'm setting up an online ordering system but I'm in Australia and for international customers I'd like to show prices in US dollars or Euros so they don't have to make the mental effort to convert from Australian dollars. Does anyone know if I can…
Adam Pierce
  • 33,531
  • 22
  • 69
  • 89
112
votes
18 answers

Displaying the Indian currency symbol on a website

This symbol for the rupee, the currency of India, was approved by the Union Cabinet on 15 July 2010. How can I display it on a website?
JustLearn
  • 3,645
  • 10
  • 29
  • 30
108
votes
22 answers

How to format decimals in a currency format?

Is there a way to format a decimal as following: 100 -> "100" 100.1 -> "100.10" If it is a round number, omit the decimal part. Otherwise format with two decimal places.
DD.
  • 21,498
  • 52
  • 157
  • 246
95
votes
14 answers

Representing Monetary Values in Java

I understand that BigDecimal is recommended best practice for representing monetary values in Java. What do you use? Is there a better library that you prefer to use instead?
dshaw
  • 2,129
  • 2
  • 14
  • 17
1
2 3
99 100