How to prevent variable going below zero?


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,692


    Did you find this post helpful? Yes | No

    Default Re: How to prevent variable going below zero?

    I do not trust that this may be the case for any PIC though.
    its a quick easy test to check, it works on all chips that i tried just make sure the compiler dosn't compress the subtract into a decrement
    i var can be byte or word

    Code:
    
    j=8 
    i=6 
    while j 
    status=1
     i=i-2  ;subtractant cannot be 1 
    s=status 
    debug 13,10,"status ",bin8 s ,"  i ",    dec i 
    j=j-1 
    wend
    
    Warning I'm not a teacher

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Re: How to prevent variable going below zero?

    Well, thanks for checking out. Wow!

    Ioannis

Similar Threads

  1. Assigning a string variable to another string variable
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd June 2013, 18:55
  2. Variable within Variable
    By munromh in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th January 2009, 15:44
  3. Electrical Current Does Prevent Corrosion?
    By T.Jackson in forum Off Topic
    Replies: 13
    Last Post: - 18th March 2008, 14:13
  4. One variable made up of another variable
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 1st September 2007, 01:18
  5. 2 variable
    By isaac in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th May 2004, 22:59

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts