thanks a lot guys, i think there's a minor glitch with the programming.
It's working now with DIG.
But the mathematical approach was good.
thanks a lot guys, i think there's a minor glitch with the programming.
It's working now with DIG.
But the mathematical approach was good.
Dig is great function but how to find out how many digits in the number if you dont know it, and what Dig function will do if you try to asses position what do not exist ?
W0 = 54321
B1 = W0 DIG 6 <---?
Last edited by therian; - 8th January 2007 at 11:51.
Hi,
The manual says:
This makes sense since the largest variable supported by PBP is 16bits so a word sizes variable can't be more than 5 digits.DIG returns the value of a decimal digit. Simply tell it the digit number (0 - 4 with 0 being the rightmost digit) you would like the value of, and voila.
If you have a word sized variable and it's value is 23 and you ask for DIG 2 it will return the value 0 since your variable is 00023.
HOWEVER, the program compiles just fine even if you say DIG 6. I don't know what it will return. Perhaps it "spills" over into the next byte in RAM.
/Henrik Olsson.
Originally Posted by therian, The Rian who asked the question
What I get from the question is this:
W0 is WORD
Say W0 = 23.
That makes it W0 = 00023.
IF you want to know which digits are NOT zero then you need a "check" routine.
Example: W1 = 00103. We have two zeros we do not need. So DIG3 and DIG4 are not required to be read (for some logical reason!)
I think this is what the question was asking.
In that case, starting from Left to Right, we have a check routine.
Do I make dead comments again?Code:IF W1 DIG 4 = 0 THEN IF W1 DIG 3 = 0 THEN ... ELSE 'Do something.... ELSE 'Do something.... .... etc.
wait, does it mean PBP will make word always 5 digit and byte 3 digit? hm I newer seen it in my book
Last edited by therian; - 9th January 2007 at 01:26.
Hi,
I don't really follow you here....
A word is always 16bits (0-65535) so yes, 5 digits. Digits "not used" will return a 0 when used with the DIG operator. If you are using the DIG operator for display purposes and don't want to display the zeros you need to use a check routine like in Sayzer's example.
/Henrik Olsson.
I just wanted to build couple 7 led displays so I was thinking about how to measure how many digits in the number to send each number to led display
Bookmarks