• Status: Solved
• Priority: Medium
• Security: Public
• Views: 127

# Large, VERY Large numbers.

I am currently working on a VB program to tell me how many possible combinations of a password there is.

What I am doing is:

Password Length ^ (to the power of) 255.

When I get above 6 ^ 255, there isn't a data-type to hold it.

How can I overcome this problem.
0
ozzie_man
1 Solution

Commented:
This is simple, use a String and NOT an Integer
Example:

Dim strCombos As String

strCombos = 6 ^ 255
0

Commented:
Well, strings are simple, but Chuckie_ice is assuming you don't want to perform any operations on the numbers. It sounds like your program might just be "incrementing" the total, so that might be true, and a string will do fine (although you'll need to write code to increment it). If you want more operators(addition, multiplication, etc.), you'll need a code library for really big integers. There's a good VB.NET library for arbitrarily big integers at < http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=403&lngWId=10 >; I'm not sure what's out there for VB6.

Good luck,
0

Commented:
Put the number you want in a TextBox so:

'Assuming it is Text1
Text1.Text = 6^255

'Use Val to 'convert' the text in the textbox to a number
strCombos = Val(Text1.Text)

You can put the textbox somewhere where the users can't see it.
Hope this helps...
0

Commented:
Oops, forgot that strCombos can't hold the converted number, so you have to use Val(Text1.Text) in every calculation instead of using strCombos!!
0

Commented:
Hello!

The question here is how much acuracy do you really need?

VB Offers several Datatypes you can use for this... Lets see which ones can hold 255^6 (Your Formula is the wrong way arroung... its 255 Possible letters per digit) - Also several dont make sense for passwords ... so i would suggest to use (36*2+12)^len(password) to get a "resonable" guess ;) (A-Z,a-z,1-0,!"Â§\$%&/()=?*+'_-:.;,<>)

Anyway... Back to datatypes ;)

6^255 = 2,68267985373259e+198 (=Double)
255^6 = 274941996890625 (Long)

DOUBLE     8 Bytes
-1.79769313486232E308 bis -4.94065645841247E-324 for negative Values,
4,94065645841247E-324 bis 1,79769313486232E308 for positive Values und 0.

Another Possibility would be Currency ,

Thats a 8-Byte Integer  / 10000 and will have the best acuracy when it comes to "digits"
0

Commented:
ozzie_man, you may also consider that users do not have access to the full 256 ascii characters, unless these passwords are being created without human interaction.  In practice, english language users will have access to ASCII 32 to 126.
0

Commented:
a double data type will hold (in your case) up to 16^255

However, like rdrunner said above, it will give you a rounded value after 15 or 16 digits.
0

Commented:
ozzie_man:
Experts: Post your closing recommendations!  Who deserves points here?
0

Commented:
ozzie_man, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
0

Commented:
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

## Featured Post

Tackle projects and never again get stuck behind a technical roadblock.