Patrick Earl wrote:
> 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. :)

You could store your exact precision numbers as a pair of integers representing 
a numerator/denominator ratio and then have math operators that work on these 
pairs like they were one number.  You would then know at the end how to move 
the 
radix point since that was kept track of along with the number. -- Darren Duncan

> 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.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to