How to preserve accuracy dealing with very large numbers?
Author Message
How to preserve accuracy dealing with very large numbers?

I need to operate with very large numbers (e.g. 1.2345678E +280).
Obviously, VB cannot "squeeze" a number like that into 8 bytes of a double
type,
and it rounds it up.  Is there any way to preserve accuracy and have the
number available for simple arythmetic operations?

Any suggestions are greatly appreciated...

Mon, 20 Nov 2000 03:00:00 GMT
How to preserve accuracy dealing with very large numbers?

Quote:

>I need to operate with very large numbers (e.g. 1.2345678E +280).
>Obviously, VB cannot "squeeze" a number like that into 8 bytes of a double
>type,
>and it rounds it up.  Is there any way to preserve accuracy and have the
>number available for simple arythmetic operations?

There are several large-integer libraries available for C++, but I don't
know of any available for VB.  You could check one of those libraries
like FreeLIP to see the techniques they use.  The algorithms for large
integer math are also discussed in Knuth's book,  The Art of Computer
Programming Volume 2: Seminumerical Algorithms.

If anyone knows of any large integer packages for VB, please let me
know because I'm in the same boat.  If not, I guess you could wait until
I have time to produce one myself...

Michael

Tue, 21 Nov 2000 03:00:00 GMT
How to preserve accuracy dealing with very large numbers?

Quote:

> I need to operate with very large numbers (e.g. 1.2345678E +280).
> Obviously, VB cannot "squeeze" a number like that into 8 bytes of a double
> type,
> and it rounds it up.  Is there any way to preserve accuracy and have the
> number available for simple arythmetic operations?

> Any suggestions are greatly appreciated...

The type "double" holds numbers up to 1.79769313486232 E +308 (for the
positive portion). You shouldn't have problems in your operations. Do you
convert a number from a control (like the text in a TextBox) to the type
double?

Michel Zwarts

Tue, 21 Nov 2000 03:00:00 GMT
How to preserve accuracy dealing with very large numbers?

Hello Dimitri,

Quote:
>I need to operate with very large numbers (e.g. 1.2345678E +280).
>Obviously, VB cannot "squeeze" a number like that into 8 bytes of a double
>type,
>and it rounds it up.  Is there any way to preserve accuracy and have the
>number available for simple arythmetic operations?

>Any suggestions are greatly appreciated...

An old programmers trick for this is to use two double precision variables to store one number, one for the fraction and one for the non-fraction part.  You will need special subroutines/functions to handle this but it can be done.

Charles E. Bortle, Jr.

Wed, 22 Nov 2000 03:00:00 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages