|
-
June 13th, 2004, 04:25 PM
#1
Rma
In code how does one count the digits of a very large number?
The number has over 50,000 digits, and is of the form k*2^n -1.
With(k<2^n)
Thanks in advance!
-
June 13th, 2004, 11:21 PM
#2
This is a start, crude but it may help a little.
All you need is a textbox and button. Im not sure but an integer has a limit, you may have to use long or something else but check on it because Im not sure.
Code:
Private Sub Command1_Click()
Dim number As String
Dim count As Integer
number = Text1.Text
count = Len(number)
MsgBox count
End Sub
R.L.T.W. A+, NET+, CCNA
doin' my best
-
June 14th, 2004, 03:59 PM
#3
longs integers
dedub
Thanks for the Text idea.
I was thinking of log (k*2^n-1),
but one still has to write (k*2^n-1).
I believe integers and longs both have limits, so
I thought maybe by knowing the exponent, and multiplier
it would be easier to calculate the number of digits.
This is a statistical function of my free software to find large prime numbers. An older version is available here: http://15k.org/rma/
The new version 1.7 rocks! but is still in progress...
-
June 26th, 2004, 05:50 AM
#4
solution
The answer is to break it up, duh....
floor(n*log(2)/log(10)) + log(k) + 1
Thanks to Chris Caldwell for some help with base 2.
Last edited by TT(n); June 26th, 2004 at 08:03 PM.
-
June 26th, 2004, 03:27 PM
#5
Digit counter for bases
Static Function Log10(k)
Log10 = log(txtInputk) / log(10)
End Function
Private Sub cmdlog_Click()
Dim loginput As Long
Dim logoutput As Variant
Dim strlog As String
Dim n As Long
Dim z As Long
n = txtInputn
z = txtInputn * 0.301029995 ' or log(2)
loginput = txtInputk
logoutput = txtlog
txtlog = Log10(k)
strlog = txtlog
strlog = Left$(strlog, 2)
txtlog = strlog + 1
txtlog = txtlog + z
End Sub
In the above code, different bases can be used by replacing base 2.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|