Generating digits of PI in Octal

Just starting out? Need help? Post your questions and find answers here.
User avatar
matalog
Enthusiast
Enthusiast
Posts: 301
Joined: Tue Sep 05, 2017 10:07 am

Generating digits of PI in Octal

Post by matalog »

How would I go about generating many digits of PI in Octal in PB?

1 billion digits would be a good start. I can see downlaods of pi to a trillion digits in decimal or hex, but didn't find any Octal.
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Generating digits of PI in Octal

Post by jacdelad »

I don't understand the question. Do you already have the digits and want to convert it or do you want to generate them "live".

Also: Why?
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
juergenkulow
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 25, 2019 10:18 am

Re: Generating digits of PI in Octal

Post by juergenkulow »

Code: Select all

PiOctal$="3.1103755242102643021514230630505600670163211220111602105147630720020273724616611633104505120207461615002335737124315474647220615460126051557445742415647741152665552434110571102665354611363754336423041351514337553260577727133364015337557343415376655211477226564762202137045437714444503145075471055475604001745612054357602630664440660705272346464426177243751114753740662535107562435331303430571526101025225671732512203560455131553160606523445274460023613506601062414041370312202744305615547073707171671301401641401633117016427300364243732705273701572305131167425713755125300561407145244574725125527121272211414230764024200527121626505252610266551461341501050172147241251032573707135144731756050105433373605212724705272720301437331627037026467036230752772656431554111475343643112340224225414734734364423032645671537422777201554612020623303540116317544152310510371261402736620014567604272567514127266167023043005655450670404342237201647132546120755533771603750410711340550440522204100021516217011247417633274207063204136672266"
PiDecimal$="3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759009946576407895126946839835259570982582262052248940772671947826848260147699090264013639443745530506820349625245174939965143142980919065925093722169646151570985838741059788595977297549893016175392846813826868386894277415599185592524595395943104997252468084598727364469584865383673622262609912460805124388439045124413654976278079771569143599770012961608944169486855584840635342207222582848864815845602850601684273945226746767889525213852254995466672782398645659611635488623057745649803559363456817432411251507606947945109659609402522887971089314566913686722874894056010150330861792868092087476091782493858900971490967598526136554978189312978482168299894872265880485756401427047755513237964145152374623436454285844479526586782105114135473573952311342716610213596953623144295248493718711014576540359027993440374200731057853906219838744780847848968332144571386875194350643021845319104848100537061468067491927819119793995206141966342875444064374512371819217999839101591956181467514269123974894090718649423196156794520809514655022523160388193014209376213785595663893778708303906979207734672218256259966150142150306803844773454920260541466592520149744285073251866600213243408819071048633173464965145390579626856100550810665879699816357473638405257145910289706414011097120628043903975951567715770042033786993600723055876317635942187312514712053292819182618612586732157919841484882916447060957527069572209175671167229109816909152801735067127485832228718352093539657251210835791513698820914442100675103346711031412671113699086585163983150197016515116851714376576183515565088490998985998238734552833163550764791853589322618548963213293308985706420467525907091548141654985946163718027098199430992448895757128289059232332609729971208443357326548938239119325974636673058360414281388303203824903758985243744170291327656180937734440307074692112019130203303801976211011004492932151608424448596376698389522868478312355265821314495768572624334418930396864262434107732269780280731891544110104468232527162010526522721116603966655730925471105578537634668206531098965269186205647693125705863566201855810072936065987648611791045334885034611365768675324944166803962657978771855608455296"
PiHex$="3.243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89452821e638d01377be5466cf34e90c6cc0ac29b7c97c50dd3f84d5b5b54709179216d5d98979fb1bd1310ba698dfb5ac2ffd72dbd01adfb7b8e1afed6a267e96ba7c9045f12c7f9924a19947b3916cf70801f2e2858efc16636920d871574e69a458fea3f4933d7e0d95748f728eb658718bcd5882154aee7b54a41dc25a59b59c30d5392af26013c5d1b023286085f0ca417918b8db38ef8e79dcb0603a180e6c9e0e8bb01e8a3ed71577c1bd314b2778af2fda55605c60e65525f3aa55ab945748986263e8144055ca396a2aab10b6b4cc5c341141e8cea15486af7c72e993b3ee1411636fbc2a2ba9c55d741831f6ce5c3e169b87931eafd6ba336c24cf5c7a325381289586773b8f48986b4bb9afc4bfe81b6628219361d809ccfb21a991487cac605dec8032ef845d5de98575b1dc262302eb651b8823893e81d396acc50f6d6ff383f442392e0b4482a484200469c8f04a9e1f9b5e21c66842f6e96c9a670c9c61abd388f06a51a0d2d8542f68960fa728ab5133a36eef0b6c137a3be4ba3bf0507efb2a98a1f1651d39af017666ca593e82430e888cee8619456f9fb47d84a5c33b8b5ebee06f75d885c12073401a449f56c16aa64ed3aa62363f77061bfedf72429b023d37d0d724d00a1248db0fead349f1c09b075372c980991"
PiSexagesimal$="3.8:29:44:0:47:25:53:7:24:57:36:17:43:4:29:7:10:3:41:17:52:36:12:14:36:44:51:50:15:33:7:23:59:9:13:48:22:12:21:45:22:56:47:39:44:28:37:58:23:21:11:56:33:22:40:42:31:6:6:3:46:16:52:2:48:33:24:38:33:22:1:0:1:40:29:38:6:8:59:13:41:2:28:16:43:56:40:7:14:57:49:58:2:15:16:1:15:57:3:24:59:18:19:13:6:47:50:31:11:14:39:23:55:6:13:39:13:12:6:55:21:32:32:26:50:16:1:44:57:19:35:1:17:0:12:57:5:32:52:18:3:0:37:8:57:41:19:16:58:49:17:44:28:9:36:42:43:1:58:22:14:24:43:45:10:20:24:7:54:19:20:57:5:20:13:44:20:45:35:0:34:12:45:32:25:59:38:16:51:9:36:7:5:47:30:41:28:31:8:29:10:46:51:27:53:45:47:20:48:46:49:26:16:53:52:18:36:1:13:14:12:18:4:21:26:46:42:20:35:23:16:8:16:56:3:22:12:42:24:27:47:6:31:44:25:11:19:16:13:25:25:36:6:1:34:18:35:39:23:59:52:34:28:51:6:52:8:56:22:42:51:24:30:31:35:23:17:21:12:49:18:24:3:29:2:27:8:8:10:18:51:21:12:26:23:43:0:20:51:0:19:39:43:11:48:18:23:21:37:29:37:28:37:59:4:59:18:46:1:5:9:44:50:55:24:25:1:59:58:41:7:26:37:42:28:37:13:29:15:30:51:13:11:22:36:7:51:33:15:17:4:54:55:46:56:49:30:37:12:16:46:1:1:55:59:17:7:1:40:38:42:50:35:0:38:34:32:13:55:26:18:9:18:45:58:8:31:26:7:15:20:52:53:15:34:24:9:47:39:57:32:20:30:34:12:7:39:28:40:26:16:14:7:35:59:44:15:24:13:19:49:5:5:41:39:44:53:11:18:12:47:24:34:59:30:15:34:54:11:5:39:21:39:46:15:22:36:43:20:44:19:46:24:49:42:44:42:54:5:45:14:5:2:1:47:35:45:58:30:9:8:19:30:46:16:29:33:1:44:20:2:1:11:41:8:32:35:24:46:15:31:9:0:30:47:21:31:7:36:20:27:52:24:23:1:0:7:45:51:53:37:45:50:7:2:29:48:42:43:46:6:24:38:49:34:3:0:34:0:27:53:59:48:50:44:41:18:45:22:28:22:13:47:44:50:8:8:6:43:11:49:45:0:9:28:15:58:49:45:48:12:42:45:11:17:41:51:43:49:57:36:50:0:24:20:25:11:29:58:51:13:38:10:16:12:53:56:39:14:33:13:31:27:7:29:22:54:59:41:1:14:57:52:37:0:12:57:2:41:17:8:31:57:6:9:56:24:36:51:53:39:53:15:4:32:16:20:23:8:36:24:21:52:54:2:56:17:0:50:44:23:49:42:10:39:2:48:18:53:49:30:17:48:24:59:56:37:15:0:29:1:6:15:12:13:35:54:13:19:13:7:15:43:5:35:42:10:48:36:43:43:28:36:44:13:56:56:47:38:47:48:37:55:46:26:27:1:49:30:43:45:46:34:53:30:12:15:46:58:50:58:33:43:38:56:1:22:59:28:31:9:16:6:28:25:32:59:8:4:33:29:46:59:56:55:21:27:56:38:59:38:0:13:35:1:34:42:56:45:29:43:49:42:17:16:48:22:2:3:44:16:7:55:21:23:58:32:31:47:42:21:12:45:0:0:22:22:42:57:12:54:13:3:4:45:22:22:43:11:44:57:4:13:45:9:56:50:37:35:28:42:54:11:55:48:37:52:41:16:56:57:1:43:37:30:37:0:8:24:16:19:43:26:43:12:19:9:50:31:0:10:2:19:9:16:19:6:20:17:59:2:44:6:27:0:45:54:56:50:27:10:23:37:33:29:32:53:10:27:15:47:3:48:56:47:5:2:48:17:49:48:6:54:20:52:9:27:54:53:57:48:26:21:49:26:21:47:32:41:39:36:47:23:3:22:5:11:45:33:1:39:12:25:49:22:4:0:19:6:26:44:27:22:14:19:20:30:38:59:52:32:47:18:0:42:28:1:18:58:6:27:45:27:44:27:27:40:36:17:18:37:45:15:15:41:50:13:37:31:38:5:47:36:48:32:53:4:40:51:38:3:10:17:31:51:36:11:36:45:52:29:15:24:55:40:44:9:46:40:32:32:41:45:56:17:50:48:28:51:49:38:47:50:4:5:7:13:53:36:57:45:43:27:32:22:45:38:59:54:7:27:20:34:17:12:12:10:39:4:33:51"
User avatar
matalog
Enthusiast
Enthusiast
Posts: 301
Joined: Tue Sep 05, 2017 10:07 am

Re: Generating digits of PI in Octal

Post by matalog »

jacdelad wrote: Tue May 07, 2024 1:26 am I don't understand the question. Do you already have the digits and want to convert it or do you want to generate them "live".

Also: Why?
As the question asks, I want to generate many digits of PI in Octal. I cannot find a source of them around, like there are sources of digits of PI in Dec and Hex.

I just want to generate them. I can then strore them and process them later on.
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Generating digits of PI in Octal

Post by Michael Vogel »

If you have the hex values already, octal is also given, so you don't need to calculate it again...

Just rearrange the bit representation from 4 bit to groups of 3 bits:

3 . 2 4 3 F...
0011 . 0010 0100 0011 1111 ...
-011 . 001 001 000 011 111 1...
3 . 1 1 0 3 7 ...
User avatar
matalog
Enthusiast
Enthusiast
Posts: 301
Joined: Tue Sep 05, 2017 10:07 am

Re: Generating digits of PI in Octal

Post by matalog »

I don't have the binary digits of PI, I have text files with the first billion HEX or DEC values.

Which would be easier to convert to Octal?
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Generating digits of PI in Octal

Post by Demivec »

matalog wrote: Tue May 07, 2024 8:22 pm I don't have the binary digits of PI, I have text files with the first billion HEX or DEC values.

Which would be easier to convert to Octal?
The HEX values.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Generating digits of PI in Octal

Post by wilbert »

Hex values indeed.
In hex representation 12 bits equals 3 digits, in octal representation 12 bits equals 4 digits.
If you want the output again to be a string, you can use a simple lookup table with 4096 entries.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Generating digits of PI in Octal

Post by Michael Vogel »

As said...

Code: Select all

Global Dim Lookup.s(4095)

Procedure InitLookup()

	Protected.i i,j
	Protected.s s

	For i=0 To 4095
		s=RSet(Bin(i),12,"0")
		For j=0 To 3
			Lookup(i)+Str(Val("%"+Mid(s,j*3+1,3)))
		Next j
	Next i

EndProcedure
Procedure.s HexToOct(s.s)

	Protected.i n,l
	Protected.s o
	
	n=1
	l=Len(s)

	While n<l
		o+Lookup(Val("$"+LSet(Mid(s,n,3),3,"0")))
		n+3
	Wend
	
	ProcedureReturn o

EndProcedure

InitLookup()
Debug "3."+HexToOct("243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89452821e638d01377be5466cf34e90c6cc0ac29b7c97c50dd3f84d5b5b54709179216d5d98979fb1bd1310ba698dfb5ac2ffd72dbd01adfb7b8e1afed6a267e96ba7c9045f12c7f9924a19947b3916cf70801f2e2858efc16636920d871574e69a458fea3f4933d7e0d95748f728eb658718bcd5882154aee7b54a41dc25a59b59c30d5392af26013c5d1b023286085f0ca417918b8db38ef8e79dcb0603a180e6c9e0e8bb01e8a3ed71577c1bd314b2778af2fda55605c60e65525f3aa55ab945748986263e8144055ca396a2aab10b6b4cc5c341141e8cea15486af7c72e993b3ee1411636fbc2a2ba9c55d741831f6ce5c3e169b87931eafd6ba336c24cf5c7a325381289586773b8f48986b4bb9afc4bfe81b6628219361d809ccfb21a991487cac605dec8032ef845d5de98575b1dc262302eb651b8823893e81d396acc50f6d6ff383f442392e0b4482a484200469c8f04a9e1f9b5e21c66842f6e96c9a670c9c61abd388f06a51a0d2d8542f68960fa728ab5133a36eef0b6c137a3be4ba3bf0507efb2a98a1f1651d39af017666ca593e82430e888cee8619456f9fb47d84a5c33b8b5ebee06f75d885c12073401a449f56c16aa64ed3aa62363f77061bfedf72429b023d37d0d724d00a1248db0fead349f1c09b075372c980991")
User avatar
matalog
Enthusiast
Enthusiast
Posts: 301
Joined: Tue Sep 05, 2017 10:07 am

Re: Generating digits of PI in Octal

Post by matalog »

Thanks for the tips guys. I was able to get what I needed from that.

It turned out, that base-4 was more suitable for me, and I was able to turn each hex digit from the txt file into a number between 0 and 15, then convert that to binary, making sure it had at least 4 digits, then convert the 2 sets of 2 binary digits in each one, into 2 base-4 numbers and going from there.

Initially I though Octal would be good, but base-4 was better.
Post Reply