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  
 
 [ 4 post ] 

 Relevant Pages 

1. Explination of how ADODB deals with a large number of records

2. Inserting large number of records into a large table with SQL/DAO

3. Managing/processing a large number of large arrays

4. How to deal with Windows LARGE Fonts?

5. Help dealing with large tables/recordsets.

6. Dealing with large Fonts

7. Dealing with LARGE Font Desktops

8. Preserve compatibility doesn't preserve compatibility

9. Dealing with numbers

10. large number of execute statements / memory leak ?

11. ItemAdd event doesn't occur when a large number of items are added at once

12. Large number of list templates in a word 2000 doc

 

 
Powered by phpBB® Forum Software