Hi,
I know brainfuck is not assembly, however i figured it is close enough :P
I was basically just wondering if anyone had an idea on how to print a multi digit representation of a byte in brainfuck (As in a byte that is 241 will print "241")
Thanks :)
Printing multi digit decimal representation of a byte in Brainfuck
Started by minime12358, Oct 10 2011 05:51 PM
5 replies to this topic
#1
Posted 10 October 2011 - 05:51 PM
|
|
|
#2
Posted 11 October 2011 - 12:05 PM
This doesn't answer your question, but you may find this and this interesting. I just simply don't feel like writing a program to do this at the moment, maybe I will feel like it later. Here may be a basic layout of how the program will go, though:
Use that "divmod" algorithm found at the bottom of the second page to divide by 10 and mod by 10 at the same time. On the first run through, the output of mod 10 will be the first digit to the right (eg for your case '1'). Then you run the algorithm on the original number divided by 10, and use the mod 10 output as the next digit from the right (in your case '4'). You would want to use a loop that would run until the divide by 10 output is zero. Which, of course, can only be up to 3 iterations of the loop for brainfuck.
Also, this forum probably wasn't the best place to ask this question. I couldn't say where you should have posted though.
Use that "divmod" algorithm found at the bottom of the second page to divide by 10 and mod by 10 at the same time. On the first run through, the output of mod 10 will be the first digit to the right (eg for your case '1'). Then you run the algorithm on the original number divided by 10, and use the mod 10 output as the next digit from the right (in your case '4'). You would want to use a loop that would run until the divide by 10 output is zero. Which, of course, can only be up to 3 iterations of the loop for brainfuck.
Also, this forum probably wasn't the best place to ask this question. I couldn't say where you should have posted though.
Latinamne loqueris?
#3
Posted 11 October 2011 - 03:02 PM
@minime12358: brain-what? I thought that was a bad word. It should probably rather be called brain* , I think.
#4
Posted 11 October 2011 - 06:38 PM
@Rhetorical: That's the name of a language that was basically designed to be a nightmare to program in, or very close to a Turing Machine, depending on your perspective.
#5
Posted 12 October 2011 - 03:16 PM
#6
Posted 19 October 2011 - 01:48 PM
mebob said:
Also, this forum probably wasn't the best place to ask this question. I couldn't say where you should have posted though.
The General Programming forum.
sudo rm -rf /
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









