How to: Hold the Largest Possible Number in a Variable
A variable holds the largest possible numbers with precision if you declare it to be of data type Decimal. The next largest integer capacity is data type ULong. If you do not need the precision of integral data types, you can use floating-point types for even greater magnitude.
Two Different Meanings for "Largest"
Largest Precise Value. If you need to hold large integers with complete precision down to the units digit, you can use the 7.9...E+28).. The Decimal type can hold integers from -79,228,162,514,264,337,593,543,950,335 through 79,228,162,514,264,337,593,543,950,335 (
Greatest Magnitude. The fractional types Single and Double can hold numbers of greater magnitude, but not with exact precision. Theprovides 8 digits of precision, and the provides 18 digits of precision.
To hold the largest possible integers in a variable
Declare the variable with a.
Follow the variable name with an As clause, specifying the Decimal keyword.
Dim atomsInTheUniverse As Decimal
Efficient Data Types
The Decimal type has the slowest performance of all the elementary numeric data types. If your integer numbers do not attain such large values and are always positive or zero, consider the ULong type.
A variable of the 1.8...E+19). Operations with ULong numbers are much faster than with Decimal, although not quite as efficient as with UInteger.can hold integers from 0 through 18,446,744,073,709,551,615 (
To hold large nonnegative integers in a variable with efficient performance
Declare the variable with a Dim statement.
Follow the variable name with an As clause, specifying the ULong keyword.
Dim atomsInTheEarth As ULong