完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在我问我的问题之前,是双滴答、Dibble Dabble和“换档加3法”都是一样的吗?我看到所有三个名字都被扔在网上,他们似乎都做着同样的事情。我的问题是:我知道BCD二进制是0000到1001。这是我上一班之后应该有的。但最后一个转变是什么呢?每个移位之后,在BCD列中可以找到的最大二进制数是什么,其中可能需要添加数字3?我问,因为如果二进制数大于12,就有一个进位位。在第五位创建的意义上的进位位。如果发生这种情况,我该怎么办?如果这种情况发生。没有提到我在哪里。谢谢。
以上来自于百度翻译 以下为原文 Before I ask my question, is Double Dabble, Dibble Dabble, and the "Shift Add 3 Method" all the same thing? I see all three names being thrown around online and they all seem to do the same thing. My question: I know that BCD binary is 0000 to 1001. This is what I should have after the last shift. But what about all the shift before the last? After each shift, what's the largest binary number that can be found in a BCD column, where the number 3 might need to be added? I ask because if the binary number is greater than 12, there's a carry bit. A carry bit in the sense that a 5th bit is created. If this happens, what do I do with it? If this even happens. It's mentioned no where that Ive seen. Thanks. |
|
相关推荐
9个回答
|
|
您也可以在这里查看HTTPS://E.WiKiTo.Org/Wiki/Doul
以上来自于百度翻译 以下为原文 You could also check here https://en.wikipedia.org/wiki/Double_dabble |
|
|
|
简而言之,值0到4的加倍会导致一个有效的BCD数字,但是值5到9的加倍会导致一个无效的BCD数字。因此,对于大于4的值,在移位之前加倍之前添加3将产生有效的BCD数字;例如(5 + 3)& lt;lt;1=10(十六进制)。
以上来自于百度翻译 以下为原文 In short, doubling the value 0 to 4 results in a valid BCD digit, but doubling the value 5 to 9 results in an invalid BCD digit. So for values greater than 4, add 3 before the subsequent doubling by the shift will yield a valid BCD digit; e.g. (5 + 3) << 1 = 10 ( hexadecimal). |
|
|
|
增量保证了一个值5,递增和左移,变成16,从而正确地“携带”到下一个BCD数字。“我知道怎么做它,我只是不完全理解它是如何工作的。我想知道的是,有没有13个我需要添加3?还是14?大于12的数字。如果我完全理解这一切如何运作,我可能会回答我自己的问题。
以上来自于百度翻译 以下为原文 "The increment ensures that a value of 5, incremented and left-shifted, becomes 16, thus correctly "carrying" into the next BCD digit." I understand how to do it, I just don't fully understand how it works. What I want to know is, could there ever be a 13 that I'd need to add 3? Or 14? Any number greater than 12. If I fully understood how this all worked I could probably answer my own question. |
|
|
|
为什么不直接使用模拟器或调试器,然后通过代码来自己查看呢?
以上来自于百度翻译 以下为原文 Why don't you just use the simulator or debugger and step thru the code to see it for yourself? |
|
|
|
维基百科的例子对我来说足够清晰,我从来没有看过它们:
以上来自于百度翻译 以下为原文 The Wikipedia examples look clear enough to me - I never looked at them :) |
|
|
|
是的,这些例子看起来很清楚。我知道怎么做。我只是想知道是否有一个数字大于12的场景。
以上来自于百度翻译 以下为原文 Yes, the examples look very clear. I know how to do it. I'm just wondering if there's ever a scenario where there's a number greater than 12. |
|
|
|
它之所以工作是因为二进制数的表示;例如ABCDEGH,其中它的值是a* 128 +b* 64 +c* 32 +d* 16 +e* 8 +f*4 +g*2 +h *1重写它,((和(a* 2 +b)** 2 +d)* * 2 + e)* * 2 +f)* 2 +g)*学习+这一分钟,你会看到它是一个运行的加倍总数(移位)a。使用BCD算法将二进制数转换为十进制。以下是每一个BCD数字在一个加倍之后产生的结果:0和-gt;0h或01H1-和g04h或03H3-和g06h或07H4-和g08h或09H5-和gt;10h或11H6-和gt;12h或13H7-和gt;14h或15H8-和gt;16h或17H9-和,18h或19,您可以看到,将值加倍0至4 Al。方法导致一个有效的BCD数字。但是如果值是5、6、7、8或9,那么加倍将给出不正确的(十六进制)值A、C、E、10或12。向这些值加6,得到正确的BCD数字,分别为10、12、14、16或18;例如A+ 6=10H。为了实现这一点,添加3,然后移位等于6;例如(5 +3)& lt;1=10H.你看到大于12的BCD数字吗?
以上来自于百度翻译 以下为原文 It works because of the representation of a binary number; e.g. abcdefgh where its value is a*128 + b*64 + c*32 + d*16 + e*8 + f*4 + g*2 + h*1 Rewriting it, ((((((a*2 + b)*2 + c)*2 + d)*2 + e)*2 + f)*2 + g)*2 + h Study this for a minute and you'll see it is a running total of doubling (shifting) a bit and adding the next bit. Now apply the above to convert a binary number to decimal by using BCD arithmetic. Here are what each BCD digit resulted after a double and add the next bit: 0 -> 00h or 01h 1 -> 02h or 03h 2 -> 04h or 05h 3 -> 06h or 07h 4 -> 08h or 09h 5 -> 10h or 11h 6 -> 12h or 13h 7 -> 14h or 15h 8 -> 16h or 17h 9 -> 18h or 19h As you can see, doubling the values 0 to 4 always results in a valid BCD digit. But if the value is 5,6,7,8, or 9 then doubling will give an incorrect (hex) value A,C,E,10, or 12. Adding a 6 to these values yields the correct BCD digits of 10,12,14,16, or 18; e.g. A+6=10h. To implement this, add 3 and then shift is equivalent to adding 6; e.g. (5+3)<<1=10h. Do you see a BCD digit greater than 12? |
|
|
|
我已经写了所有的解码我的二进制到BCD,它的工作很漂亮。我只是想知道我是否可以结束一个大于12的BCD。我很好奇,在加3之前最大的值是多少,5或更大。我将不得不阅读你写的另一个时间来尝试我的头脑。我的大脑现在被炸了。只花了一两天的编码。
以上来自于百度翻译 以下为原文 I already wrote all the to decode my binary to BCD and it works beautifully. I only was wondering if I could end up with a BCD greater than 12. I'm curious as to what the largest value, 5 or greater, can be before adding 3. I'm going to have to read through what you wrote another time to try and wrap my head around this. My brain is fried right now. Just spent a day or two coding. |
|
|
|
从你的其他帖子来看,你好像在为16F83进行汇编。为什么要重新发明轮子?在这个论坛和Web上,有许多二进制到BCD例程很容易获得。就像我前面说过的,通过模拟器或调试器运行二进制到BCD例程,您将亲自查看。
以上来自于百度翻译 以下为原文 From your other posts, it looks like you're coding in assembly for a 16F883. Why re-invent the wheel? There are many binary to BCD routines readily available in this forum and the web. Like I said earlier, run a binary to BCD routine thru the simulator or debugger and you will see it for yourself. |
|
|
|
只有小组成员才能发言,加入小组>>
5160 浏览 9 评论
1998 浏览 8 评论
1927 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3170 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2225 浏览 5 评论
730浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
628浏览 0评论
526浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 16:12 , Processed in 1.437879 second(s), Total 92, Slave 75 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号