Link to home
Start Free TrialLog in
Avatar of ozzie_man
ozzie_man

asked on

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.
Avatar of Chuckie_Ice
Chuckie_Ice

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

Dim strCombos As String

strCombos = 6 ^ 255
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,
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...
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!!
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"
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.
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.  
ozzie_man:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Avatar of DanRollins
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
ASKER CERTIFIED SOLUTION
Avatar of YensidMod
YensidMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial