Storing currency values in SQLite3

Viewed 27955

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 and requires more precision?

6 Answers

In financial software currency is always represented as fixed-point (decimal). You can emulate it in SQLite using integers (64-bit integer holds up to 18 digits).

I see this post is long ago, but anybody noticed there is a money type out now for sqlite :D

Related