Math Operations on pbp


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    May 2007
    Location
    San Jose, Costa RIca
    Posts
    2

    Question Math Operations on pbp

    Hi!
    i'm new here!
    i've been around looking for answers that may help me. I need some math operations but they have to be "kind of" signed.
    Let me see if I understood: If i use "+" or "-" actually i won´t have a signed result 'cause i´m not using "signed math".... BUT if i make something like 8-10 .... so.... i´ll have my answer in complement to two??

    What i need is a calculation like:
    m(k) = 100 e(k) - 81e(k-1) + 100 m(k-1)

    (yes... it's part of an iterative algorithm)
    I don't need to know if m(k) is positive or negative (in good theory it will be positive each time!) just need every operation goes correct w/its respective sign.... so can I JUST use add and subtract commands of PBP??

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


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    May 2007
    Location
    San Jose, Costa RIca
    Posts
    2


    Did you find this post helpful? Yes | No

    Red face Tnx

    I already have read that....
    just wanna be sure if I understood as I said
    I´m not sure if in that case i need or not, use the "S"
    Thats what i need to know

    tnx again

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


    Did you find this post helpful? Yes | No

    Default

    I think you are looking for the Absolute Value of a number.

    8-12=(-4)
    The absolute value is |4|

    PBP has an ABS function.

    Example:
    NUM = 8-12
    NUM2 = ABS NUM

    NUM2 will now be |4|
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Math operations & Syntax?
    By kevj in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 23rd February 2008, 01:40
  2. instruction cycles for math operations
    By Michael Wakileh in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th July 2007, 11:03
  3. Another math problem for PBP
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd April 2005, 20:59
  4. Nasty PBP math help ?
    By Martin in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 30th March 2005, 09:46
  5. PBP 16-bit ADC result math
    By sonic in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 13th March 2005, 14:21

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