-
Notifications
You must be signed in to change notification settings - Fork 0
/
pi.bf
37 lines (27 loc) · 1.74 KB
/
pi.bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
========================================================================
=========================== INPUT NUMBER ==============================
========================================================================
>+[->,----------[<+>-------------------------------------->[>+>+<<-]>>[<<
+>>-]<>>>+++++++++[<<<[>+>+<<-]>>[<<+>>-]<[<<+>>-]>>-]<<<[-]<<[>+<-]]<]>
>[<<+>>-]<<
<[-]
========================================================================
============================== PROCESS =================================
========================================================================
[ yet another pi calculation program in bf
Just like for pi16.b the accuracy of the result depends on the cellsize:
- using 8 bit cells causes an overflow after 4 digits
- using 16 bit cells causes an overflow after 537 digits
- using 32 bit cells causes an overflow after several millions of digits
It's about ~38 times shorter than pi16.b, ~364 times faster and works with
not-wrapping (bignum) implementations.
by Felix Nawothnig ([email protected]) ]
> Put the number of digits you want in this cell
[<+>>>>>>>>++++++++++<<<<<<<-]>+++++[<+++++++++>-]+>>>>>>+[<<+++[>>[-<]<[>]<-]>>
[>+>]<[<]>]>[[->>>>+<<<<]>>>+++>-]<[<<<<]<<<<<<<<+[->>>>>>>>>>>>[<+[->>>>+<<<<]>
>>>>]<<<<[>>>>>[<<<<+>>>>-]<<<<<-[<<++++++++++>>-]>>>[<<[<+<<+>>>-]<[>+<-]<++<<+
>>>>>>-]<<[-]<<-<[->>+<-[>>>]>[[<+>-]>+>>]<<<<<]>[-]>+<<<-[>>+<<-]<]<<<<+>>>>>>>
>[-]>[<<<+>>>-]<<++++++++++<[->>+<-[>>>]>[[<+>-]>+>>]<<<<<]>[-]>+>[<<+<+>>>-]<<<
<+<+>>[-[-[-[-[-[-[-[-[-<->[-<+<->>]]]]]]]]]]<[+++++[<<<++++++++<++++++++>>>>-]<
<<<+<->>>>[>+<<<+++++++++<->>>-]<<<<<[>>+<<-]+<[->-<]>[>>.<<<<[+.[-]]>>-]>[>>.<<
-]>[-]>[-]>>>[>>[<<<<<<<<+>>>>>>>>-]<<-]]>>[-]<<<[-]<<<<<<<<]++++++++++.