Hi Everyone:
I am running a program in both VB6.0 or VB 2008, and I am running into a lot
of round-off error due to my sets of data. In some occasions, I get the
data to be all in the same of order of magnitude, where all is fine, and
other times, the data have really different orders of magnitude, which is
when the round-off error shows in the calculations. So, the type Double
does not give me a good precision.
I was wondering if in VB, is there any way of going to quadruple precision
or better precision than Double? Any help from the experts and MVP's are
appreciated. Thanks;
Bob
Bob O`Bob - 11 Jul 2008 18:29 GMT
> I am running a program in both VB6.0 or VB 2008, and I am running into a lot
> of round-off error due to my sets of data. In some occasions, I get the
[quoted text clipped - 6 lines]
> or better precision than Double? Any help from the experts and MVP's are
> appreciated. Thanks;
You certainly could create a class which handles arbitrary precision
math, or likely any other such thing you need. I've seen implementations
like complex numbers, arbitrary precision using byte arrays, and some
other wild stuff. No sample code to share, though - sorry.
Using just two Doubles might get you to within a few bits of
quad-precision. I'm not sure if I would approach it quite that
simplistically, though. For that sort of thing, Byte Arrays have
become my hammer of choice - sometimes you can emulate an external
storage type right in memory, and greatly reduce the translations
necessary for API calls or I/O using the target type.
Of course, in VB6 you can't overload operators, so you pretty much
won't be able to use those.
Bob
[MVP Classic VB]
--
Bob - 11 Jul 2008 21:01 GMT
Hi Bob:
thanks for your reply. Your explanation of byte arrays, I guess, is over my
head as I am not familiar with them. I was hoping for some other relatively
simple trick or solution. I guess if nothing else comes, I will look into
learning that. Thanks;
Bob
>> I am running a program in both VB6.0 or VB 2008, and I am running into a
>> lot of round-off error due to my sets of data. In some occasions, I get
[quoted text clipped - 25 lines]
> [MVP Classic VB]
> --
MikeD - 11 Jul 2008 22:58 GMT
> Hi Everyone:
>
[quoted text clipped - 8 lines]
> or better precision than Double? Any help from the experts and MVP's are
> appreciated. Thanks;
Curious. What do you mean VB6 or VB2008? Are you saying you're indifferent
as to which you use? In that's the case, you really first need to pick one
or the other. And then, depending on which you pick, post your question in
the appropriate newsgroup. Also, examples of the kind of data you're
working with might have been helpful.
How many decimal places are you dealing with? If 4 or less, you might find
working with the Currency data type to be better than Double (at least in
VB6). The Currency data type is a scaled integer, so there won't be rounding
errors or other problems that are possible with either Single or Double. I
can't tell you if this is the same in VB2008.

Signature
Mike
Microsoft MVP Visual Basic
Bob - 12 Jul 2008 08:38 GMT
Mike:
I am looking for 15 to 25 digits. So, neither double nor currency work for
me. The reason I am indifferent to VB6.0 or 2008 is that in which ever
version I can get the thing to work, I am going to use that version.
Bob
>> Hi Everyone:
>>
[quoted text clipped - 20 lines]
> rounding errors or other problems that are possible with either Single or
> Double. I can't tell you if this is the same in VB2008.
Larry Serflaten - 12 Jul 2008 22:02 GMT
> I am looking for 15 to 25 digits. So, neither double nor currency work for
> me. The reason I am indifferent to VB6.0 or 2008 is that in which ever
> version I can get the thing to work, I am going to use that version.
>
> Bob
Look up the Decimal type in VB Help and see if that will fill your need.
LFS
senn - 12 Jul 2008 06:45 GMT
> Hi Everyone:
>
[quoted text clipped - 10 lines]
>
> Bob
Try a look at this site;
I think your best choice will be xnumbersdll.zip
Unless intended for use in Vista.
Read warnings, first on the site.
http://digilander.libero.it/foxes/SoftwareDownload.htm
If you find it useable, then give the credit to the
two times Bob.
/senn
Bob - 12 Jul 2008 23:28 GMT
Thanks Senn. I think you are right. This at least gives me something to go
by. I think it will help a lot, and again thanks. I appreciate it.
Bob
>> Hi Everyone:
>>
[quoted text clipped - 20 lines]
>
> /senn