BrainFuck part 6 - 16-bit integers

DPAmar
9,229 views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Sample

Now, we are done. In any code we already have, we can simply replace the 8 instructions by our overriden ones to work on 16-bits.

As an example, let's transform the Fibonacci sequence source code from previous playground. Warning : it's a bit long, but you can now ask for 256th or more items (up to 65535).

Note that values themselves will still be displayed modulo max value (65536 instead of 256)

Minified version

>>>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>[<-]<[>>[-<+>]<[[->+<]<->]<<]>-[[-]><+
>[<-]<[->>-<<<]>>-<<<<<+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>
+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>>>>>><+>[
<-]<[>>[-<+>]<[[->+<]<->]<<]>-]>>>>>,>[-]<<+>[<-]<[>>[-<+>]<[[->+<]<->]<<]>-[[-]>>>>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>>
<+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>[<-]<[>>[-<+>]<[[->+<]<->]<<]>-[[-]><+>[<-
]<[->>-<<<]>>-<<<<<+>[<-]<[->>-<<<]>>-<+>[<-]<[->>-<<<]>>-<+>[<-]<[->>-<<<]>>-<+>[<-]<[->>-<<<]>>-<+>[<-]<[->>-<<<]>>-<+>[<-]
<[->>-<<<]>>-<+>[<-]<[->>-<<<]>>-<+>[<-]<[->>-<<<]>>->>>><+>[<-]<[>>[-<+>]<[[->+<]<->]<<]>-]>>>>><+>+[<-]<[->>+<<<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-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>
[<-]<[>>[-<+>]<[[->+<]<->]<<]>-[[-]><<<<<+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[
<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>>>>>><+>[<-]<[->>-<<<]>>-<+>[<-]<[>>[-<+>]<[[->+<]<
->]<<]>-]><<<<<+>[<-]<[->>-<<<]>>-.<+>[<-]<[>>[-<+>]<[[->+<]<->]<<]>-[[-]><+>[<-]<[->>-<<<]>>-<+>[<-]<[>>[-<+>]<[[->+<]<->]<<
]>-]><<<<<+>[<-]<[>>[-<+>]<[[->+<]<->]<<]>-]><<<<<<<<<<<<<<<<<+>[<-]<[>>[-<+>]<[[->+<]<->]<<]>-]>
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content