List:General Discussion« Previous MessageNext Message »
From:Jon Frisby Date:October 23 2002 7:51pm
Subject:RE: Rounding floats
View as plain text  
Another alternative for storage of currency values is to use the DECIMAL
type, which allows you to explicitly specify scale and precision.
You're still constrained to a maximum precision that matches that of
DOUBLE, and you get the inefficiency of storing values as strings but
you don't have to worry about rounding errors. (unless you're recording
truly enormous sums of money...)

-JF

> -----Original Message-----
> From: gerald_clark [mailto:gerald_clark@stripped] 
> Sent: Wednesday, October 23, 2002 10:10 AM
> To: Jan Steinman
> Cc: mysql@stripped
> Subject: Re: Rounding floats
> 
> 
> Oh, for BCD floating point.
> My first computer with a language (SWTP 6800) had BCD math.
> It had something like 6 byte mantissa and a 1 byte exponent.
> That would give 11 digits with e +-99
> Maybe we should have BCD data types.
> 
> Jan Steinman wrote:
> 
> >>From: "Michael T. Babcock" <mbabcock@stripped>
> >>Kenneth Hylton wrote something about SQL or QUERYs:
> >>    
> >>
> >>>I NEVER use float or double to store values like you 
> appear to be doing...
> >>>      
> >>>
> >>FWIW, all of our financial database software stores values 
> in either pennies or tenths of a cent, not dollars, to avoid 
> decimals altogether.
> >>    
> >>
> >
> >FLOAT + money = lawsuit :-)
> >
> >  
> >
> 
> 
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <mysql-thread123073@stripped>
> To unsubscribe, e-mail 
> <mysql-unsubscribe-jfrisby=yourfreedvds.com@stripped>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 
> 

Thread
Rounding floatsMichael T. Babcock23 Oct
Re: Rounding floatsJan Steinman23 Oct
  • Re: Rounding floatsgerald_clark23 Oct
    • RE: Rounding floatsJon Frisby23 Oct
      • Vague error message...Jon Frisby23 Oct