Forums - Open Redstone Engineers
Signed Binary to BCD - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: ORE General (https://forum.openredstone.org/forum-39.html)
+--- Forum: School Discussion (https://forum.openredstone.org/forum-51.html)
+--- Thread: Signed Binary to BCD (/thread-13163.html)



Signed Binary to BCD - Mandelbrot_86 - 10-04-2017

I'm planning on making an 8-bit binary to bcd decoder. (In minecraft) The part that is making it weird is that I'm doing it with signed binary. I'm obviously not the first to attempt this. My current thought is that I just create a regular bcd decoder, but I precede it with an operation where the leading bit is read and if it's a 1, it carries an extra bit to the display to light the minus and it converts the number to its Twos Complement and runs it through the regular bcd. Does anyone have any ideas for a conditional Twos Complement converter? I think I can do it with adders, but it seems like there might be an easier way or maybe a completely different binary to bcd method besides double dabble which will make this unnecessary.


RE: Signed Binary to BCD - konsumlamm - 10-04-2017

You're searching for something like this:

https://youtube.com/watch?v=emAJnA_Gw_U

It is horizontal, but i guess you should be fine with that, since that probably the style you're building in right now. It is just a conditional two's complement converter, you just need to connect the sign bit to the control (wether or not to convert). For information about how it works, just watch the video.


RE: Signed Binary to BCD - Mandelbrot_86 - 10-04-2017

Yeah. I'm doing most of my work horizontally right now deliberately. I can build vertical adders watching tutorials, but I don't always understand why certain redstone setups are functioning as specific gates. (Also, I find it harder to stack vertically without using WE) The creator of the tutorial seems to confirm that I'm thinking correctly about signed binary to BCD conversion. His converter doesn't seem much simpler than what I'd already thought of, though. It looks like he's essentially using XOR logic to conditionally invert and then CIN to half adders. The only thing that makes his design better than my current plan is the insta-carry instead of ripple carry. If there really isn't a shortcut way to do this, I'm cool with building my original design. I'll probably look a little more into insta-carry though since I want it to be at least reasonably fast.


RE: Signed Binary to BCD - Koyarno - 10-04-2017

2s complement values just work well with anything except 7segment displays; they cant handle the input well if its negative. So only solution is to check if the highest value bit is on, make the display use a minus symbol instead and invert + add 1 to the value.

If you feel up for it, try a sequential bcd decoder, they are more fun :]


RE: Signed Binary to BCD - Mandelbrot_86 - 10-04-2017

Oh I understand the logic. That's what my current plan was. I just wasn't liking how big and slow my 2s compliment converter seemed to be when I was diagramming it (Not huge, but big enough to be frustrating.) Like I say I can use the first bit to conditionally invert my bits using XOR and to light the carry-n to Half Adders. I'm basically making an absolute value function I was just hoping someone had figured out a super fast or at least super small shortcut for this seeing as I'm sure everyone with 7 segment displays has come across this.


RE: Signed Binary to BCD - konsumlamm - 10-04-2017

(10-04-2017, 04:01 PM)Mandelbrot_86 Wrote: I was just hoping someone had figured out a super fast or at least super small shortcut for this seeing as I'm sure everyone with 7 segment displays has come across this.

that's about as fast and compact as you can get it...