Re: Double data Type limits

Tech-Archive recommends: Fix windows errors by optimizing your registry




"Bob" <someonw@xxxxxx> wrote in message
news:%23$xEK%23vCJHA.4724@xxxxxxxxxxxxxxxxxxxxxxx
Hi Everyone:

I was just goofing around, and I was wondering if anyone knows of any
example that can get around the limits of a Double data type in VB 6. For
example if you look at the calculator in windows, you can easily go beyond
the limits of double, e.g. 1000! (factorial of 1000).

I appreciate any resources or web sites you can give me.


A Double is a floating point number stored as eight bytes (64 bits). The
range of numbers you can hold in a Double is vast: from positive 1.79E308 to
negative 1.79E308. A Double is limited to 15 significant figures.

That limitation also actually skews the scale of the data. As the Integer
portion grows the scale of the fractional portion decreases.

But you asked what if we want to represent even larger numbers?

The clue to how to do that is contained in VB's Currency Datatype. It
permits up to 15 digits to the left of the decimal point, resulting in a
range of approximately -922,337,000,000,000 to +922,337,000,000,000.
Currency is actually an integer type internally. It is scaled by a factor of
10,000 to give four digits to the right of the decimal point. You can apply
this design by writing your own wrapper for multiple longs. Each
representing a factored range.

There is probably some code out there for doing this. Of course some numbers
are not worth it. We can easily write an expression that represents a number
greater than grains of sand in the Universe. <g>

-ralph


.



Relevant Pages

  • Re: Double data Type limits
    ... example that can get around the limits of a Double data type in VB 6. ... portion grows the scale of the fractional portion decreases. ... The clue to how to do that is contained in VB's Currency Datatype. ... 10,000 to give four digits to the right of the decimal point. ...
    (microsoft.public.vb.controls)
  • Re: Rounding info needed-A2k
    ... But, instead of saving the entered amount -1353.57, it's stores ... accurate out to 82 million digits ... I chose the number/double type over the currency because I didn't like the ... you have a floating point data type. ...
    (comp.databases.ms-access)
  • Re: 15 Significant Digits Limitation a Mistake for Spatial Informa
    ... DP does not restrict to 15 decimal digits. ... Input and output precision are more tightly linked in Excel ... Decimal data type or roll your own extended precision data types. ...
    (microsoft.public.excel)
  • Re: Working with large numbers
    ... > I am writing an application the must use large numbers(16-20 digits). ... > I am using double data type but vb by default converts the following ... Dim Value1 As Variant ... if a Variant variable is assigned a value that was cast ...
    (microsoft.public.vb.general.discussion)
  • Re: Rounding info needed-A2k
    ... If you use a Number field, you have a floating point data type. ... This is really useful for handling enormous numbers or miniscule numbers (hundreds of zeros after the decimal point before the digits really start), but they are limited to around 15 significant digits Most fractional numbers cannot be stored precisely in this binary form, just as many numbers cannot be stored precisely in the decimal form without an infinite number of digits. ... Therefore you will need to use Roundwhen performing calcuations that write a value so the Currency field, so ensure the last 2 digits are stored as zeros. ... I also have a control on a form that is either visible or not based on comparing a simple check amount entry of 3145.54 to a sum of the payments, all entered as individual dollar, cents entries that eventually SHOULD total the check amount. ...
    (comp.databases.ms-access)