Jump to content

Calculating Pi


erifash
 Share

Recommended Posts

Yes the output is correct...

141592653589793238462643383279 - Ruby*

141592653589793238462643383279 - AutoIt (Larry)

502884197169399375105820974944

502884197169399375105820974944

592307816406286208998628034825

592307816406286208999184097971

[*Ruby output as claimed by http://www.cs.utsa.edu/~wagner/pi/pi10000dig.html]

I'm not sure which is correct...

"I'm just sayin'."

Paul Reiser (aka. Paul Buchman)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

That is one nice piece of code. It is accurate too (the 40 digits I know at least). At my school we have Pi Day where people from each class compete by memorizing as many digits of pi as they can. Our school record is 230 something digits.

Link to comment
Share on other sites

$PI = 22 / 7
MsgBox(0,"",$PI)
Tru Pi is not 22 / 7, despite what some places might say o:)

Pi is an irrational decimal, meaning it is absolutely impossible to represent it as a fraction.

;)

Matt :lmao:

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

nice. so which is correct?

...like I'd know. :-)

...but one could ask David B. http://crd.lbl.gov/~dhbailey/pi/index.html

(Anyone up for the conversion of the Fortran-90 or C programs there?)

...or dig around in here http://oldweb.cecm.sfu.ca/projects/pihex/

Interesting graphs: http://oldweb.cecm.sfu.ca/projects/pihex/status.html

OR is it all just a cruel joke on mankind?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

...like I'd know. :-)

...but one could ask David B. http://crd.lbl.gov/~dhbailey/pi/index.html

(Anyone up for the conversion of the Fortran-90 or C programs there?)

...or dig around in here http://oldweb.cecm.sfu.ca/projects/pihex/

Interesting graphs: http://oldweb.cecm.sfu.ca/projects/pihex/status.html

OR is it all just a cruel joke on mankind?

6 billion digits arleady calculated. nice.
Link to comment
Share on other sites

hi, in case anyone doesnt know, i'm kevin, and i found my old rewritten script for pi, turns out it wasnt in autoit, but ti-89 basic lol, so i converted it, and it worked! however, it got really screwy with the output, take a look:

script:

$n = 0
$pi =""
$pistr = ""
$k = 2
$a = 4
$b = 1
$a1 = 12
$b1 = 4
While 1
    $p = $k * $k
    $q = 2 * $k + 1
    $k = $k + 1
    $aold = $a1
    $bold = $b1
    $a1 = $p * $a + $q * $a1
    $b1 = $p * $b + $q * $b1
    $a = $aold
    $b = $bold
    $d = Int($a / $b)
    $d1 = Int($a1 / $b1)
    While $d == $d1
        $n += 1
        If $n == 2 Then
            $pi &= "." & String($d)
        Else
            $pi &= String($d)
        EndIf
        $pistr &= $pi
        $pi = ""
        $a = 10 * Mod($a, $b)
        $a1 = 10 * Mod($a1, $b1)
        $d = Int($a / $b)
        $d1 = Int($a1 / $b1)
    WEnd
WEnd

Func OnAutoItExit()
    FileWrite("pi.txt", $pistr)
EndFunc

output:

3.141592653-9223372036854775808-92233720368547758089223372036854775807-9223372036854775808-9223372036854775808-9223372036854775808922337203685477580792233720368547758079223372036854775807922337203685477580792233

72036854775807-9223372036854775808-92233720368547758089223372036854775807-9223372036854775808-922337203685477580892233720368547758079223372036854775807-92233720368547758080000000000000000000...

go figure... i wanna kno whats up with the negatives, im wondering if its something to do with some bad binary conversions on the C side of autoit. cya!

i own this sig... php rulezlinks:My PSP Web Portal
Link to comment
Share on other sites

notice that every "-" is followed by 9.

hmm. I wish i understood the code in the first place. could someone point me to the exact code that is being used here?

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

Change your code and see if you see the problem:

$pistr &= $pi

MsgBox(0,"pi",$pistr)

$pi = ""

$a = 10 * Mod($a, $:lmao:

MsgBox(0,"$a",$a)

$a1 = 10 * Mod($a1, $b1)

MsgBox(0,"$a1",$a1)

Edit: this is about like the code posted earlier in this thread:

http://www.autoitscript.com/forum/index.ph...ndpost&p=140881

I added the boxes to that code and saw the same thing - not that I know what to do about it - just noticed it.....

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

whoa. confusing.

there must be a logical explanation for the "-"s, and why they are always followed by a 9. but i dont know it :lmao:

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

You're overflowing something in the second while loop. You're either overflowing a double or an int somewhere in that code. Once you do that, you basically blow the whole algorithm up. You have to write code that calculates pi without overflowing the limits of a double or 32-bit integer (Maybe 64-bit, I'm a bit fuzzy on how AutoIt determines 32/64 bit ints).

The algorithm is at fault, though, I can tell that much by looking at some variable traces while it runs.

Link to comment
Share on other sites

You're overflowing something in the second while loop. You're either overflowing a double or an int somewhere in that code. Once you do that, you basically blow the whole algorithm up. You have to write code that calculates pi without overflowing the limits of a double or 32-bit integer (Maybe 64-bit, I'm a bit fuzzy on how AutoIt determines 32/64 bit ints).

The algorithm is at fault, though, I can tell that much by looking at some variable traces while it runs.

BTW - In hexadecimal the two "overflow numbers" (-9223372036854775808 and 9223372036854775807) that I see are 0x8000000000000000 and 0x7FFFFFFFFFFFFFFF respectively. The latter being the number limit of AutoIt. I converted them using calc.exe.

EDIT: I was debugging Kevin's code and it turns out that the variables $a and $a1 are overflowing.

Edited by erifash
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...