brainfuck

Brainfuck compare 2 numbers as greater than or less than

亡梦爱人 提交于 2019-11-28 02:39:59
问题 How can I compare two numbers with an inequality? (greater than or less than) I want to compare single digits For example 1 2 5 3 9 2 etc. 回答1: This is the best way to compare two numbers.Why because, if you are intelligent enough, you can use the same code in bigger programs.It's highly portable. Assume we have two numbers a,b. we have two blocks : if( a>=b ) and else , Hope its enough. 0 1 0 a b 0 Make the array like this. And point to the (4) i.e. point to the a +>+< This is for managing

How to calculate the sum of 2 numbers with BrainFuck

蹲街弑〆低调 提交于 2019-11-27 02:03:47
问题 I'm trying to write a program with BrainFuck that can read two numbers up to 9, calculate the sum of them and then print the result out, e.g. 3 & 5 give the result 8 . I'm just trying to understand the BF language but it looks much harder than I thought it would be. 回答1: Think of the language as a huge tape (30K bytes long) where you can read, write and move forward or backward and increment/decrement one cell at a time (each cell being 1 byte, so you effectively have 30K cells). Optionally,