You could look into BCD (Binary Coded Decimal) math if you are going to do
your own data type and math.  Working with integers and moving the decimal
place is most likely the easiest,  It is the method I use when not working
with Borland products.  (Borland supports BCD data types.  Specifically for
the reasons you suffer from.)  Floating point is damn near useless IMHO.

Fred

> -----Original Message-----
> From: Randall Fox [mailto:[EMAIL PROTECTED]
> Sent: Saturday, June 05, 2004 5:20 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [sqlite] Adding and subtracting decimals is not accurate
>
>
> On Fri, 04 Jun 2004 23:46:06 -0400, you wrote:
>
> >Welcome to the wonderful world of floating point numbers :-)
> >
> >I always store money values as cents (or as integers, what ever your
> >currency might call it) and move the decimal to format for display..
>
> Yes, I took a closer look at floating point addition using my
> compiler.  This does indeed work.  I was worried that once the number
> got put into a floating point notation, the error would still creep
> up, but I didn't get that, even when adding millions of numbers.
>
> Still, this is a little awkward (but workable)..  I may have to make a
> special "MONEY" type for users, and every time convert it to cents..
> Hmm..
>
> Thanks
>
> Randall Fox
>
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to