PBPL 2.50b (possible) For/Next ?BUG? or just the way it is...


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest

    Default PBPL 2.50b (possible) For/Next ?BUG? or just the way it is...

    While working/testing/failing those souped up divide routines, I came across something.
    Don't know if it's a bug, or just plain unavoidable...
    Code:
    mn = -2147483600 'almost max'd out at 31 bits
    mx = 2147483600 'almost max'd out at 31 bits
    st = 1234567 'step size can vary quite a bit
    x var long
    
    For x = mn to mx step st
         lcdout $fe , 1 , HEX4 x.word1 , ":" , HEX4 x.word0
    Next x
    The loop never stops! Ever!
    It seems that when the step size is larger than the difference between 2^31 -1 and mx, x will roll over from a positive number to a negative number (high bit set) and the loop will keep running. Conversely, if using a negative step size, x will roll over from a negative number to a positive number and the loop will keep running as before.
    Looks to me like it's an unavoidable situation...
    Any thoughts?

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    If the "step" is to big no matter what size of variable, (byte,word) wouldn't the same thing happen, a roll over?
    Dave
    Always wear safety glasses while programming.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    If the "step" is to big no matter what size of variable, (byte,word) wouldn't the same thing happen, a roll over?
    I would think so. But it seems that with PBPL that internally everything is dealt with as though it were a LONG (case in point, those division routines I've been monkeying with). I'm fairly sure the rest of the math is dealt with in the same fashion. Therefore, a byte or word, might not act the same way. Not sure. It's just something I noticed yesterday.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    It will be the weekend before I get back to the bench. I am going to play with it.

    I was playing with a taylor series awhile back and gave up, thought it was me and my bad coding... probably was but maybe it is something with PBPL?
    Dave
    Always wear safety glasses while programming.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I was playing with a taylor series awhile back and gave up, thought it was me and my bad coding... probably was but maybe it is something with PBPL?
    Not a Darrell Taylor series I hope!!!

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Not a Darrell Taylor series I hope!!!
    Nope. But might be some relation.

    This Taylor
    http://en.wikipedia.org/wiki/Brook_Taylor
    any resemblance?
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. PBP and PBPL
    By keymuu in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 30th January 2009, 17:58
  2. USB PBPL Compile errors
    By Rob in forum USB
    Replies: 11
    Last Post: - 7th April 2008, 08:18
  3. IF..AND/OR..THEN and PBPL
    By duncan303 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 25th January 2008, 16:45

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