![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Does anyone have such an algorithm? Or something similar? I don't want to have to re-invent the wheel. Len | |
| |
| | (permalink) |
| That's quite a significant amount of digits. Are these to be displayed, such as an on an LCD? In that case, converting them to ASCII would be better. You aren't planning on stringing up an unholy number of seven-segment displays to a poor little PIC are you :?: What is your application? | |
| |
| | (permalink) |
| well, I did convert 40-bits to BCD long time ago. but..hm... couldnt understand my own code when i look at it now to convert 8 bit to BCD, it could be done by using divisio by 10 to get quotient and remainder.(refer to college book on digital circuit) the tough part is to convert 64 bit when ur microcontroller is only 8 bit. take out a piece of paper, calculate by hand, 123456 / 10. The 1st step u do to divide 123456 by 10 is to divide 12 by 10, get the remainder, which is 2. Then multiply 2 with 10 and add the following digit, 3, to make it 23. Then u divide 23 with 10... and so on. got it? you will get 12345 as quotient, and 6 as remainder. The '6' will be the least significant bit of BCD. Repeat the step, you will get 5, then 4... and eventually 1. to do it in 8 bit, first, divide MSB by 10, get the quotient and remainder. Then, multiply the quotient with 256 instead of 10 (cause 1 byte=256) and add with the following byte. Therefore, u need to define the quotient as 16 bits. The rest of the steps are identical with above. confusing? yea.. even me myself not sure what i'm talking about. pls forgive me i give wrong information mistakenly | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) | |
| Quote:
I'm presuming that you're looking for Binary to Decimal (and not actually BCD), everyone seems to incorrectly use BCD these days. BCD is packing two decimal digits in one 8 bit byte, some older processors even had special modes to do maths on BCD bytes - which was extremely useful. | ||
| |
| | (permalink) |
| Thanks for the responses, gives me food for thought. Len | |
| |
| | (permalink) | |
| Quote:
| ||
| |