views:

88

answers:

5

I'm going to make a computer in Minecraft. I understand how to build a computer where it can make binary operations but I want the outputs to be displayed as standard integer numbers. How you "convert" the binaries into standard digits? Is there any chart for that? And the digits will be shown like in old calculators; with 7 lines.

 --
|  |
 --
|  |
 --
+1  A: 
0 = 0
1 = 1
10 = 2
11 = 3
100 = 4
101 = 5
110 = 6
111 = 7
...

Do you see the pattern? Here's the formula:

number = 2^0 * (rightmost digit)
       + 2^1 * (rightmost-but-1 digit
       + 2^2 * (rightmost-but-2 digit) + ...
Domenic
I was thinking that too... but somehow I don't think that's quite what he's looking for. He's clever enough to build a machine that does binary addition... and if you watch the vid, he knows how to read the numbers too ;)
Mark
Good point, haha.
Domenic
+1  A: 

I think's that's two different questions.

There isn't a "binary string of 0/1" to integer conversion built in - you would normally just write your own to loop over the string and detect each power of 2.

YOu can also write your own 7segment LED display - it's a little tricky because it's on multiple lines, but would be an interesting excersize.

Alternatively most GUIs have an LCD font,Qt certainly does

Martin Beckett
+1  A: 

Maybe what you are looking for is called BCD or Binary Coded Decimal. There is a chart and a karnaugh map for it that has been used for decades. a quick Google search for it gave me this technical page http://circuitscan.homestead.com/files/digelec/bcdto7seg.htm

How are you trying to build the computer? Maybe that key word can at least help you find what you need. :)

Watki02
+2  A: 

In electronics, what you need is called a "binary to binary coded decimal" converter. "Binary coded decimal" is the set of bits needed to produce a number on a 7 segment display. Here's a PDF describing how one of these chips works. Page 3 of the PDF shows the truth table needed to do the conversion as well as a picture of all of the NAND gates that implement it in hardware. You can use the truth table to build the set of boolean expressions needed in your program.

David
+1  A: 

Your problem has two parts:

  1. Convert a binary number into digits, that is do a binary to BCD conversion.

  2. Convert a digit into a set of segments to activate.

For the latter you can use a table that assigns the bitmap of active segments to each digit.

starblue