not quite understanding the MATH function


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest

    Default not quite understanding the MATH function

    I am still in the learning phase. Just complete one program and moving on to hte other. The second program is based around plenty of math. I have attached portion of my program showing the type of math that I trying to do. With it I am getting error messages in my complex math based around basic functions. I even went into the extent of breaking it down to different levels and still got error. Is there anything that anyone could hinder for a problem solving. That is in the case of me not understanding what I am doing wrong.
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    It will help if you post the part of your program where you declare all of the variables you are using, and also post the errors you are getting.

    Its not a good idea to use 0.5*(etc etc). You will be better off shifting 1 place to the right like this (etc etc)>>1.

    Also, if you are declaring variables as bytes you have to make sure you cant possibly end up with a value higher than 255 in any of your calculations.
    Last edited by Kamikaze47; - 16th January 2006 at 17:16.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    > Its not a good idea to use 0.5*(etc etc).

    Actually, it's not a good idea to use any numbers with Decimal places... Why? Because PICBasic ONLY works with INTEGERS.

  4. #4
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    Learning in the process. Thanks for the heads up. I think that is were I was getting the mistake or the headache.

    I have attached the whole prgram that I am trying to use. The problem that I am having starts with labels LIMITSA. I think that the whole problem that I am getting is with that .5

    The other thing is that I am using a linear equation to solve for a result in the range of 1 to 2. With the label PROGRAM2 you can see that I have 510 with part of the equation, but it should all come back and relate to that range of 1-2. will this be a problem.

    The equations that I would like to base all of this off of is the second line to label PROGRAM1 and PROGRAM2. The difference between the two is that of the slope.
    Attached Files Attached Files

  5. #5
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    im sorry to say there are quite a few problems with your program.

    all 11 lines with decimal numbers are invalid. This includes the lines where you multiply by 0.5 and the lines which include 1.5. As Melanie said, PBP only deals with integers.

    in one of the lines you divide something by negative 255, however PBP does not support signed variables.

    you may want to make some more variables words instead of bytes becuase it looks like some of your variables may overflow

  6. #6
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    ok. I make sense to what you are saying. Looking at what the manual has and to what you are saying. I made some correction since the last time we have talk.

    Still working out some of the kinks that are in the program so.

    I wrote out everything long hand and the other thing that I have to refresh myself up on is that >>1 = .5 ordeal. Been too long since I last seen that.

    Will work more into making sense with what you are saying and learning about that difference. Thanks
    Attached Files Attached Files

Similar Threads

  1. Resolution integer math assistance?
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th January 2010, 03:01
  2. Line Graph, math problem...
    By TerdRatchett in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th May 2009, 04:20
  3. PBPL Math...new math takes more cycles...Always?
    By skimask in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2008, 10:22
  4. Question for a math guru
    By Christopher4187 in forum General
    Replies: 3
    Last Post: - 22nd November 2006, 09:45
  5. Random function - How to limit it ??
    By martarse in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 30th November 2004, 14:05

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