Gyulay Gabor writes:

> Please let me know, how to handle huge numbers.

I'll give you a suggestion or two, but first of all
I must ask you to set your time to something more
correct. If you're in the UK (or Portugal), your time
is off by about 7 hours. If you're elsewhere, I guess
your time zone setting is wrong.

> The problem is that I need to store numbers with lot more
> than 16 decimal digits - e.g. 1234567890123456789012345.12
> I already tried a decimal type but it caused errors (I mean
> MySQL simply cutted the end of the numbers and stored only
> the first 16 digits :()

"The maximum range of DECIMAL and NUMERIC values is the same
as for DOUBLE" - I wonder how this fits with the exactness
of DECIMAL, it being stored as a string and all.

> The reason is why we need this that there're several
> currencies (like italian lire) which requires this kind of
> precision.

You must be dealing with incredible amounts of money. :-)

> One more question is how to transfer these values through
> the MySQL C api ?

I have some suggestions on how to store your numbers.
You want to go beyond 64 bits per number, so there's
not much MySQL will be able to do with your numbers
other than storing and comparing them.
If you know that all numbers you'll be handling can be
represented with no more than 36 decimal digits, you
could use two BIGINT columns. This is rather messy, but
it can be done and you'll be able to add and subtract
two numbers fairly easily. Another way to store the
numbers is in a BLOB big enough to hold any number that
you might want to put there. Use this if your application
really handles the numbers as radix 256 numbers (like
for instance the big number routines in Numerical Recipes).
Finally, if you handle numbers as strings, I can't see a
better solution than storing the numbers as strings in the
database. To be sure that comparison works, you'll want to
either prefix numbers with a byte(or two) stating their
number of digits, or pad them to the same length.

What to do really depends on how big numbers you want to
use. If you want really big numbers, I suggest that you
consider adding support for them to MySQL. I'm sure that
there are more people who would like to see MySQL capable
of handling arbitrarily big numbers, although I can see
how this would take lots and lots of work.

How does your application handle such big numbers anyway?
The highest floating point precision I'm aware of (under
normal circumstances, that is) has onle 80 bits, and quite
a few of those are used for the exponent.

//C

-- 
 Carl Troein - Círdan / Istari-PixelMagic - UIN 16353280
 [EMAIL PROTECTED] | http://pixelmagic.dyndns.org/~cirdan/
 Amiga user since '89, and damned proud of it too.


---------------------------------------------------------------------
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 <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to