PDA

View Full Version : 28 bits --> DEC output on LCD



SteveB
- 1st August 2006, 04:32
Anybody have a tidy way to display a 28 bit number on an LCD in decimal? I’m multiplying two 16 bit words, but based on the max values for each, the total should result in 28 bits or less.

Here is the way I am doing it now:
Check the high word. If it’s >0 then divide the 32 bit product (using DIV32) by a multiple of 10 (based on the value of in the high word). Then print out the result with appropriate number of trailing 0s. This has the effect of rounding off the last digits (up to 4 if the number is large).

This works well enough, but I am guessing somebody else has a better way of doing this.

Steve

Darrel Taylor
- 1st August 2006, 06:09
Steve,

A slight variation of this might work.

32-bit Variables and DIV32, Hourmeter 99999.9
http://www.picbasic.co.uk/forum/showthread.php?t=1942

The key is getting the remainder from DIV32.
<br>

SteveB
- 1st August 2006, 17:59
Perfect!


The key is getting the remainder from DIV32.

Yep, this is exactly the key I need to crack this problem. I had the "Result = DIV32 1000" part figured out, just didn't know how to get at the "bottom half" of the double word.

I really wish the search function for this forum worked a little better and accepted small terms. It might have helped me find your previous post. But I was right in my guess that someone had figured this out already. Not suprised at all that someone happend to be Darrel Taylor.

Thanks Darrel,
Steve

Darrel Taylor
- 1st August 2006, 19:33
Why...Thank you Steve!

And I seem to remember someone posting about using the google site: search instead of the forums search tool.

But I searched for it, and couldn't find it :eek:

DT