Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/18/07 08:52
Read: times


 
#133209 - Hmph?
Responding to: ???'s previous message
Am I missing something? Probably do, because you've just written following:

you have:
1) maximum number your register can hold (max)
2) operand a
3) operand b

and you want to achieve a-b operation. You have suggested following method (example is with your numbers a1=6, b1=1 and a2=6, b2=5 max=10):
1) max-a           (10-6=4 or 10-6=4)
2) (max-a)+b       ( 4+1=5 or  4+5=9)
3) max-((max-a)+b) (10-5=1 or 10-9=1)
so if you take the last equation (3) you get:
max-((max-a)+b) = max-max+a-b = a-b

So it lookes like you wish to acomplish operation "subtract by module max", e.g.
result=(a-b) mod max

If that is so then something puzzles me... For positive resulting numbers you are ok, but if your result is negative, your register should 'revolve' around max-1. For example: max=10, a=6, b=7 (subtract 6 from 7, (you should get -1) or 9 if you subtract by module 10):
1) 10-6=4
2) 4+7=11 or 1?
(here you would 'revolve' your register around max count since the assumption is it can't hold values greater than max-1 (otherwise it doesn't make sense since you get -1 as a final result) and get 1! I don't understand, this part clearly, since you'll get the same for 'rotation' around 0, not just maxint, so what's the point?
3) 10-1=9 or 10-11=-1?
But it looks like you don't need to do all this module subtracting, you can simply (as Joseph mentioned in the first place http://www.8052.com/forum/read.phtml?id=133164) update your display. Say you need to count from 10 downto 0. You set your counter to count from 0 to 10 and in each iteration you display:

display_value = max_value_to_count_to - current_count

e.g.
CNT=>MAX-CNT=Display
 0 => 10-0  = 10
 1 => 10-1  =  9
 2 => 10-2  =  8
 '''
 9 => 10-9  =  1 
10 => 10-10 =  0

Best luck,
CN

List of 7 messages in thread
TopicAuthorDate
Need HELP!!!            01/01/70 00:00      
   Your timers don\'t need to count backwards            01/01/70 00:00      
   Help on counting backwards            01/01/70 00:00      
      You lost me!            01/01/70 00:00      
      What!?!?!?!?!?            01/01/70 00:00      
         I'm glad it's not just me, then!            01/01/70 00:00      
      Hmph?            01/01/70 00:00      

Back to Subject List