Interesting, John. I'll explore that a bit. I have some library code that uses that binary-to-bcd algorithm; I should be able to play with it in reverse. Thanks for the idea. Larry At 04:35 PM 12/21/2003 -0500, you wrote: >After reading your first post, I started thinking about this. There does seem >to be a method, but I need more time to refine it. >There is a clever binary-to-BCD algorithm in the Microchip application note >which describes utility math operations (AN526. appendix K). The method >involves left shifting the BCD partial result and then "fixing up" the result. >After repeating this N times for an N-bit binary number, the BCD result is >the value of the original binary number. On close examination, you can >see that the shift and fixup operation amounts to multiplying the BCD >result by 2. >It seems to me that performing this procedure in reverse will divide the >BCD number by 2. In fact, it does. This means that if you start with >50 00 00 00 ... >in a BCD register, you can successively create >25 00 00 00 ... >12 50 00 00 ... >06 25 00 00 ... >03 12 50 00 .. >If you add these BCD numbers to a BCD accumulator, using the binary >fraction as a guide for when to add, the result will be the decimal fraction >which is equivalent to the original binary fraction. >To handle scientific notation, you must deal with large exponents. Doing >this quickly and with optimized code is the part I am still thinking about. > >John Power > >-- >http://www.piclist.com#nomail Going offline? Don't AutoReply us! >email listserv@mitvma.mit.edu with SET PICList DIGEST in the body Larry Bradley Orleans (Ottawa), Ontario, CANADA -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body