|
-
Sep 28th, 2000, 07:36 PM
#1
hello. I am trying to make a program that will write out Phi (golden ratio). here is the code that i use:
Code:
Private Sub Form_Load()
Text1.Text = .5*sqr(5) + .5
End Sub
I know the equation works out to be Phi, which as I under stand is a 216 digit number. however the number that comes out in text1.text is only the first 15 digits. is there any way to make it divide out the full amount???
-Steve
PS If I am incorect about any thing to do with Phi or the Golden Ratio, tell me.
-
Sep 28th, 2000, 07:45 PM
#2
Hyperactive Member
Decimal data type
has 28 decimal places. I think double is 15 like you have said.
If you need all of the decimal places, and you need to calculate it (rather than type them into a string for example) then you will need to write your own function for doing it.
Are you sure you need all of the decimal points and it needs to be calculated in your code?
Regards
-
Sep 28th, 2000, 08:10 PM
#3
Hyperactive Member
more help..?
I checked for you and managed to get the first 500 decimal places for Phi.
Phi is an irrational number so there is no limit to the number of decimal places. There are no formulae to predict the value of the nth decimal place either so all you can do, is write your own function to work out the sum to "infinity", stopping once you are sure you have enough detail...
Code:
Private Sub Form_Load()
Dim a As Variant
Dim b As Double
b = (1 + Sqr(5)) / 2
Text1 = b
a = CDec((CDec(1) + CDec(Sqr(CDec(5)))) / CDec(2))
Text2 = a
Text3 = "1·61803398874989484820458683436563811772030917980576" _
& "28621354486227052604628189024497072072041893911374" _
& "84754088075386891752126633862223536931793180060766" _
& "72635443338908659593958290563832266131992829026788" _
& "06752087668925017116962070322210432162695486262963" _
& "13614438149758701220340805887954454749246185695364" _
& "86444924104432077134494704956584678850987433944221" _
& "25448770664780915884607499887124007652170575179788" _
& "34166256249407589069704000281210427621771117778053" _
& "15317141011704666599146697987317613560067087480710"
End Sub
By the way, this demonstrates to me that the so called "Decimal" type which is supposed to give us 28 decimal places is pretty useless considering the sqr function is only performed as a double...
Hope it helps in a small way...
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
|