Back
Close

BrainFuck part 6 - 16-bit integers

DPAmar
9,322 views

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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]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>
[<-]<[>>[-<+>]<[[->+<]<->]<<]>-[[-]><<<<<+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[
<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>><+>+[<-]<[->>+<<<]>>>>>><+>[<-]<[->>-<<<]>>-<+>[<-]<[>>[-<+>]<[[->+<]<
->]<<]>-]><<<<<+>[<-]<[->>-<<<]>>-.<+>[<-]<[>>[-<+>]<[[->+<]<->]<<]>-[[-]><+>[<-]<[->>-<<<]>>-<+>[<-]<[>>[-<+>]<[[->+<]<->]<<
]>-]><<<<<+>[<-]<[>>[-<+>]<[[->+<]<->]<<]>-]><<<<<<<<<<<<<<<<<+>[<-]<[>>[-<+>]<[[->+<]<->]<<]>-]>
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io