Hello. Exactly as the title states.. how do I display a decimal larger than 255? I am storing a count in two bytes in an array and would like to display the 2 bytes as a decimal on the LCD which can be 0 - 65535?
Thanks!
Hello. Exactly as the title states.. how do I display a decimal larger than 255? I am storing a count in two bytes in an array and would like to display the 2 bytes as a decimal on the LCD which can be 0 - 65535?
Thanks!
Assuming using LCDOUT, and array elements are var[0] and var[1]
dec var[1] dig 2, dec var[1], dig 1, dec var[1] dig 0, dec var[0] dig 2, dec var[0] dig 1, dec var[0] dig 0
Might need a bit of a tweak, basically use the extension 'dig' to point to the digit of the 3-digit variable you wish to display. This will also display leading zeros
Deliberate mistake ;-).
Var[0] can only hold up to 255 so as it stands it may not be quite correct to adopt that technique.
What is the largest number you are using in each byte ? Does the lower byte count right up to 255 and then roll over, at the same time incrementing the higher byte ? Or, do you restrict the range of the lower byte to some other amount, such as 99 ?
If you can't jump directly to extracting the values you need using the 'dig' directive, then you can always write a short math routing to count off the two bytes.
sum var word
lower var byte
upper var byte
sum = (upper * 255) + lower
lcdout dec sum dig 4, dec sum dig 3, dec sum dig 2, dec sum dig 1 , dec sum dig 0
Should be:sum = (upper * 255) + lower
Al.Code:sum = (upper * 256) + lower
All progress began with an idea
Could it not be as simple as:-
COUNTER VAR WORD
COUNTER_H VAR COUNTER.BYTE1 'high byte
COUNTER_L VAR COUNTER.BYTE0 'low byte
LCDOUT $FE,128,DEC4 COUNTER 'top row, position 1.
Tim.
I don't think so, because although the LCDOUT is very simple and elegant, the maximum number which can be stored in either Counter_H or Counter_L is 255. Therefore the largest value which the word sized variable Counter can be is 255255.
There needs to be a conversion first. The high byte needs to be multiplied by 256 (not 255 as I originally pointed out) and then added to the low byte before it gets stored in the word 'Counter'
Last edited by Acetronics2; - 10th March 2009 at 09:06.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Last edited by Byte_Butcher; - 10th March 2009 at 02:45.
Bookmarks