Duh... what i don't understand here...
More about the calculation?Originally Posted by rlampus
Duh... what i don't understand here...
More about the calculation?Originally Posted by rlampus
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
When I take my shoes off, I can see my toes, so I can count to 20.
When I count to 5, I only need to see one hand, but to 10, I need to see both hands.
Therefore, if a word variable is 16 bits, two word variables is 32 bits. That means, if I declare a 2 element word array, I'll have 32 bits. So I'd just need a simple algorithm to refer to the array and treat it like one 32bit variable.
You could use assembler, or use any of the bit functions (>> << or var.bit) to handle it.
bcf
Originally Posted by blainecf
Hi blainecf,
I wonder what would you take off if you needed to count to 40?![]()
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
LOLOriginally Posted by sayzer
I'm still confused how you get beyond 23![]()
Keith
www.diyha.co.uk
www.kat5.tv
This is very helpful, Thankyou. Could you please give one example of actual pic basic code.Originally Posted by blainecf
r lampus
As I have said in the past, there has got to be an easier way....but this might get your ball rolling. I worked it assuming you have no WORD variables and only BYTES. (i.e., I assumed you had a 16 bit number composed of two 8 bit variables instead of your 32 bit number composed of two 16 bit words. Expanding the below to DOUBLE WORDS is similar, just a lot more lines.) (Yes, I know we have WORDS in PBP – I am just demonstrating a process). -THIS IS UNTRIED IN ACTUAL CODE BUT WORKS ON PAPER-Originally Posted by rlampus
Background
bit 1 = 1
bit 2 = 2
bit 3 = 4
bit 4 = 8
bit 5 = 16
bit 6 = 32
bit 7 = 64
bit 8 = 128
----------------
bit 9 = 256
bit 10 = 512
bit 11 = 1024
bit 12 = 2048
bit 13 = 4096
bit 14 = 8192
bit 15 = 16384
bit 16 = 32768
Good LuckCode:' Example: Dig 12345 (assuming WORDS not available) HiByte VAR BYTE LoByte VAR BYTE Digit VAR byte[5] HiByte = $30 ' high byte of 12345 ($30 = 00110000) LoByte = $39 ' low byte of 12345 Digit[0] = LoByte Dig 0 ' = 7 Digit[1] = LoByte Dig 1 ' = 5 Digit[2] = LoByte Dig 2 ' = 0 Digit[3] = 0 ' no need to dig because byte 3 decimal places max Digit[4] = 0 ' no need to dig because byte 3 decimal places max If HiByte.0 = 1 then Digit[0] = Digit[0] +6 Digit[1] = Digit[1] +5 Digit[2] = Digit[2] +2 If HiByte.1 = 1 then Digit[0] = Digit[0] +2 Digit[1] = Digit[1] +1 Digit[2] = Digit[2] +5 If HiByte.2 = 1 then Digit[0] = Digit[0] +4 Digit[1] = Digit[1] +2 Digit[3] = Digit[3] +1 If HiByte.3 = 1 then Digit[0] = Digit[0] +8 Digit[1] = Digit[1] +4 Digit[3] = Digit[3] +2 If HiByte.4 = 1 then Digit[0] = Digit[0] +6 '=13 Digit[1] = Digit[1] +9 '=14 Digit[3] = Digit[3] +4 '=4 If HiByte.5 = 1 then Digit[0] = Digit[0] +2 '=15 Digit[1] = Digit[1] +9 '=23 Digit[2] = Digit[2] +1 '=1 Digit[3] = Digit[3] +8 '=12 If HiByte.6 = 1 then Digit[0] = Digit[0] +4 Digit[1] = Digit[1] +8 Digit[2] = Digit[2] +3 Digit[3] = Digit[3] +6 Digit[4] = Digit[4] +1 If HiByte.7 = 1 then Digit[0] = Digit[0] +8 Digit[1] = Digit[1] +6 Digit[2] = Digit[2] +7 Digit[3] = Digit[3] +2 Digit[4] = Digit[4] +3 Digit[1] = Digit[1] + Digit[0] Dig 1 '=24 Digit[0] = Digit[0] Dig 0 '=5 DIGIT0 Digit[2] = Digit[2] + Digit[1] Dig 1 '=3 Digit[1] = Digit[1] Dig 0 '=4 DIGIT1 Digit[3] = Digit[3] + Digit[2] Dig 1 '=12 Digit[2] = Digit[2] Dig 0 '=3 DIGIT2 Digit[4] = Digit[4] + Digit[3] Dig 1 '=1 DIGIT4 Digit[3] = Digit[3] Dig 0 '=2 DIGIT3
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Originally Posted by paul borgmeier
Thankyou. This is very helpful.
R Lampus
You might also want to take a look at this thread http://www.picbasic.co.uk/forum/showthread.php?t=1942
I can only count to 10, toes are too far to count, belly too big to reach!Originally Posted by blainecf
Bookmarks