I am new to this language and i am building brainfuck interpreter in scala i am facing one problem what should i print if the value at memory index is greater than 127 ?
what a real brainfuck interpreter print if value is greater than 127?
for eg
memory[index]=178
when "." (print command) is called what should a brainfuck iterpreter print ?
my compiled some codes on ideone.com but it showing runtime error .
for follwing code:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[+.<-]
The original implementation for .
just calls putchar()
with whatever unsigned char
value is in the cell:
...
case '.': putchar(a[p]); fflush(stdout); break;
...
This means how characters 128-255 show up depends on what encoding your terminal uses. If I set mine to CP437, characters 32-255 look like this:
In your case, Scala's toChar
method on numbers sounds like it should do what you want; also, maybe ideone is just weird about printing extended ASCII.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With