That is true, but then when you are formulating generic queries within
a place such as an ORM like NHibernate, you would need to figure out
when to translate the user's "100" into "10000".  As well, if you
multiplied numbers, you'd need to re-scale the result.  For example,
(1 * 1) would be (100 * 100 = 10000), which is 1 * 1 = 100. :(  If one
wanted to get excessively complicated, they could implement a series
of user functions that perform decimal operations using strings and
then reformulate queries to replace + with decimal_add(x,y).  That
said, it'd be so much nicer if there was just native support for
base-10 numbers. :)

       Patrick Earl

On Sat, Mar 26, 2011 at 8:15 PM, BareFeetWare <list....@barefeetware.com> wrote:
> On 27/03/2011, at 12:39 PM, Patrick Earl wrote:
>
>> Base-10 numbers are frequently used in financial calculations because
>> of their exact nature.  SQLite forces us to store decimal numbers as
>> text to ensure precision is not lost.  Unfortunately, this prevents
>> even simple operations such as retrieving all rows where an employee's
>> salary is greater than '100' (coded as a string since decimal types
>> are stored as strings).
>
> Can you store all money amounts as integers, as the cents value? That is 
> exact, searchable etc.
>
> Thanks,
> Tom
> BareFeetWare
>
> --
> iPhone/iPad/iPod and Mac software development, specialising in databases
> develo...@barefeetware.com
>  --
> Comparison of SQLite GUI tools:
> http://www.barefeetware.com/sqlite/compare/?ml
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to