First Spear Posted March 14, 2016 Share Posted March 14, 2016 Quick! It's Pi day! Somebody calculate Pi in IntyBASIC and do something awesome! Eye on Pi 2016 Quote Link to comment Share on other sites More sharing options...
+nanochess Posted March 14, 2016 Share Posted March 14, 2016 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 2 Quote Link to comment Share on other sites More sharing options...
+5-11under Posted March 14, 2016 Share Posted March 14, 2016 This will calculate PI using IntyBASIC I did a similar calculation, but I just stuck with all integers: PI = 3 2 Quote Link to comment Share on other sites More sharing options...
+nanochess Posted March 14, 2016 Share Posted March 14, 2016 I did a similar calculation, but I just stuck with all integers: PI = 3 1 Quote Link to comment Share on other sites More sharing options...
freewheel Posted March 15, 2016 Share Posted March 15, 2016 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. 2 Quote Link to comment Share on other sites More sharing options...
+nanochess Posted March 15, 2016 Share Posted March 15, 2016 Using extra RAM (CC3 or JLP) it could fill up the screen and more Quote Link to comment Share on other sites More sharing options...
carlsson Posted March 15, 2016 Share Posted March 15, 2016 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? Quote Link to comment Share on other sites More sharing options...
+nanochess Posted March 15, 2016 Share Posted March 15, 2016 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 1 Quote Link to comment Share on other sites More sharing options...
Kiwi Posted March 15, 2016 Share Posted March 15, 2016 The best I could do is to render a 3D image of a pie. 2 Quote Link to comment Share on other sites More sharing options...
carlsson Posted March 15, 2016 Share Posted March 15, 2016 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. Quote Link to comment Share on other sites More sharing options...
+nanochess Posted March 15, 2016 Share Posted March 15, 2016 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. Quote Link to comment Share on other sites More sharing options...
carlsson Posted March 15, 2016 Share Posted March 15, 2016 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.