Jump to content
IGNORED

Pi Revisited


Recommended Posts

The topic I started about calculating Pi seems to have expired (but the one that pissed off all of the homebrew programmers still there LOL)

 

In short, I wrote a very primitive BASIC program that divided 22 by 7 and then generated random numbers after it had finished carrying that out to appear as if it was calculating Pi indefinately. I gambled that no-one would scrutinize the math and the gamble paid off I got an "A+" for an "Outstanding" science fair project.

 

My C-64 fanboy programmer pal sent me this and says a C-64 CAN do it.

 

 

What say you Atari Agers: Is this real? Can a similar program be written in Atari BASIC?

 

// Concurrent computation of pi.
//>> Dead link removed<<
//
// This demonstrates Go's ability to handle
// large numbers of concurrent processes.
// It is an unreasonable way to calculate pi.
package main

import (
"fmt"
"math"
)

func main() {
fmt.Println(pi(5000))
}

// pi launches n goroutines to compute an
// approximation of pi.
func pi(n int) float64 {
ch := make(chan float64)
for k := 0; k <= n; k++ {
go term(ch, float64(k))
}
f := 0.0
for k := 0; k <= n; k++ {
f += <-ch
}
return f
}

func term(ch chan float64, k float64) {
ch <- 4 * math.Pow(-1, k) / (2*k + 1)
}

 

 

Link to comment
Share on other sites

  • 6 months later...

Just get the C64 executable and it'll likely be easy to convert especially if it's not using any OS or Rom functions.

 

A potential problem area though is if it requires a contiguous work area, on C64 you can switch the IO area out so giving a 65534 byte contiguous Ram area.

On Atari we can only get 52K contiguous and that's regardless of amount of installed Ram (exception there can be 65816 systems using expanded addressing).

 

Alternatively though a 130XE or better banked Ram situation could allow for a more complex calculation though come with potentially high speed penalties as switching banks can slow some processes right down.

Edited by Rybags
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

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