Mikey C wrote:

John Stanton wrote:

We have added a DECIMAL type to Sqlite. This stores fixed point numbers in ASCII display format and performs accurate artithmetic and presents nicely from HTML.




In which release was the DECIMAL affinity added to SQLite? Can you specify
the precision and scale as per SQL-92 standard? e.g. DECIMAL(9,2) ?

It was not added to Sqlite releases. We added the DECIMAL type using the regular DECIMAL(n,m) notation defining precision and scale. It takes advantage of the Sqlite declared type logic, but needed a slight change to stop Sqlite treating these columns as numeric and flipping them to floating point storage. We did not integrate the decimal arithmetic into the regular SQL arithmetic, instead defining seperate decimal functions and aggregate functions.

We were using Sqlite for a commercial system and needed an appropriate fixed point number format and accurate arithmetic for money values.


John Stanton wrote:

If you store money as an integer with an "implied decimal point" (a familiar method for old-time COBOL programmers) it will work. We have added a DECIMAL type to Sqlite. This stores fixed point numbers in ASCII display format and performs accurate artithmetic and presents nicely from HTML.

Floating point numbers for money is a perennial trap for young players.

Mikey C wrote:

Hi there,

Currently I am using a SQLite 3.x database that stores and calculates
currency values using the column type NUMERIC (which I believe has a
FLOAT
affinity).

However this leads to errors in storing values values in floating point
representation.

I guess there is no planned support for direct fixed point types, so what
is
the best approach?

Store the monetary values in an INTEGER column and multiply all values up
by
100 to store in pence/cents?

Any advice?

Thanks,

Mike


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------







-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to