IGNORED

# Calculate Pi and Do Something?

## Recommended Posts

Quick! It's Pi day! Somebody calculate Pi in IntyBASIC and do something awesome!

Eye on Pi 2016

##### Share on other sites

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

##### Share on other sites

This will calculate PI using IntyBASIC

I did a similar calculation, but I just stuck with all integers:

```PI = 3
```
##### Share on other sites

I did a similar calculation, but I just stuck with all integers:

```PI = 3
```

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

##### Share on other sites

Using extra RAM (CC3 or JLP) it could fill up the screen and more

##### Share on other sites

Is that compiler bug, if it lets the user DIM an array larger than fits into the selected memory model, or should the programmer know better?

##### Share on other sites

Is that compiler bug, if it lets the user DIM an array larger than fits into the selected memory model, or should the programmer know better?

Given IntyBASIC generates a error message isn't a bug

##### Share on other sites

The best I could do is to render a 3D image of a pie.

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

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

##### Share on other sites

Yup. For instance, my intybasic-mode.el will stop the compilation in case the compiler returns anything else than zero, but I don't know about other environments and scripts.

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.