Jump to content
IGNORED

Calculate Pi and Do Something?


Recommended Posts

This will calculate PI using IntyBASIC :)

	REM
	REM Calculate digits of Pi
	REM by Oscar Toledo G. http://nanochess.org/
	REM Creation date: 3/14/16 (Mar/14/2016)

	REM Based on http://www.codecodex.com/wiki/Calculate_digits_of_pi#C

	CONST scale = 100
	CONST arrinit = 20
	CONST digits = 200	' It will generate 200/14*2 digits

	DIM arr(digits + 1)

	carry = 0
	FOR #i = 0 TO digits
	arr(#i) = arrinit
	NEXT #i

	PRINT AT 0,"Digits of PI"
	PRINT AT 20 COLOR 7
	FOR #i = digits TO 1 STEP -14
	#sum = 0
	FOR j = #i TO 1 STEP -1
	#sum = #sum * j + scale * arr(j)
	arr(j) = #sum % (j * 2 - 1)
	#sum = #sum / (j * 2 - 1)
	NEXT j
	PRINT <2>carry + #sum / scale
	carry = #sum % scale
	NEXT #i

	WHILE 1
	WEND

pi.zip

  • Like 2
Link to comment
Share on other sites

It only printed out 30 digits. I wanted to see what would happen if I messed with it. I didn't spend more than 5 seconds looking at the code, and changed CONST digits = 250.

 

What's cool is that it still works, and prints more digits. What's cooler is that it somehow triggers sound channels. Set it to 300 to make.. well not quite music, but it's cool. 400 gets weirder. Eventually the entire thing just hangs, but there's a lot of room for experimentation between 200 and 400.

 

I think I've just discovered a new form of performance art.

  • Like 2
Link to comment
Share on other sites

My fault! I assumed that "it still works" means it went through the compiler without errors, but clearly it doesn't. However an ASM file is generated anyway, which means if you didn't notice errors have occurred, you may go ahead and assemble the faulty code.

Link to comment
Share on other sites

My fault! I assumed that "it still works" means it went through the compiler without errors, but clearly it doesn't. However an ASM file is generated anyway, which means if you didn't notice errors have occurred, you may go ahead and assemble the faulty code.

 

You can always check the error level returned by IntyBASIC to command line.

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...