List:General Discussion« Previous MessageNext Message »
From:Jules Bean Date:April 20 1999 4:17pm
Subject:Re: bc math support in MySQL?
View as plain text  
On Tue, 20 Apr 1999 jkraai@stripped wrote:

> Has anyone implemented bc math support?
> 
> I'm diving into the docs now to do this and would hate 
> to carve out a wheel that already exists.
> 
> Anybody think this is a really bad idea?  Let me know.

I think it's a idea with problems - I always get upset when people, not
understanding the nature of computer mathematics, complain that a database
is 'broken' because the floating point data type is not precise.

The '=' operator is not useful for floating point.  I sometimes wish that
C didn't define an '=' operator, to ram this point home.

If you need accuracy, then you need fixed point, not floating point.  If
you want 'base 10' accuracy, then you want a fixed point format with a
denominator of the form 10^x.

A neater approach than BCD (which is just silly) would be a data type
which is fixed point, you specify the denominator.  So, if you are dealing
with currency, you might want 4 decimal places, so set the denominator to
10000.

If you are dealing with old english currency (unlikely :-) then you want
the denominator to be 240.

Essentially, this should be implemented simply as an integer, with an
automatic scale on the IO routines.

Alternatively, simply use an integer, and do the scaling in your
middleware! ;)

CREATE TABLE (a FIXED(10000));

or some such.

Jules
 
/----------------+-------------------------------+---------------------\
|  Jelibean aka  | jules@stripped         |  6 Evelyn Rd	       |
|  Jules aka     | jules@stripped              |  Richmond, Surrey   |
|  Julian Bean   | jmlb2@stripped        |  TW9 2TF *UK*       |
+----------------+-------------------------------+---------------------+
|  War doesn't demonstrate who's right... just who's left.             |
|  When privacy is outlawed... only the outlaws have privacy.          |
\----------------------------------------------------------------------/

Thread
bc math support in MySQL?jkraai20 Apr
  • Re: bc math support in MySQL?Jules Bean20 Apr
    • Re: bc math support in MySQL?Tobias Rischer21 Apr
      • Re: bc math support in MySQL?Tobias Rischer21 Apr
    • Re: bc math support in MySQL?Tobias Rischer21 Apr
      • Re: bc math support in MySQL?Jules Bean21 Apr
    • Re: bc math support in MySQL?Fred Read21 Apr
Re: bc math support in MySQL?jkraai20 Apr