H
H
hrvasiliy2016-02-07 22:11:02
MySQL
hrvasiliy, 2016-02-07 22:11:02

How to store the exchange rate?

If there are several currencies on the site, how to store the exchange rates correctly? I came to the conclusion that it is necessary to store some of the currencies as a unit, and the rest based on this unit. But what type of data should be used to store the course? As far as I understand, it is better to perform all monetary transactions in an integer data type, because there may be problems when rounding ... Will there be such problems if the rate is stored in DOUBLE, for example?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2016-02-07
@hrvasiliy

DECIMAL

P
Peter, 2016-02-07
@petermzg

numeric(10,2) или numeric(10,4)
what kind of accuracy do you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question