math help


Closed Thread
Results 1 to 4 of 4

Thread: math help

  1. #1
    houa's Avatar
    houa Guest

    Default math help

    if any can help i would really appreciate it

    here's the problem

    A=.082
    B=4.15
    C=94.2
    D=76.76

    AA=A*B
    BB=C*D
    X=-75.12+AA-BB

    E=101
    CC=E*E
    F=EE/301.6
    Y=F*703

    I read that pic basic pro doesn't support floating point numbers
    so how can i approach this problem?

    Is there an include file i can include to my problem?
    Is there a procedure to follow to calculate my answers
    I need to display it with 3 decimals places as well

    Any help will be appreciated
    thanks for looking

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    949


    Did you find this post helpful? Yes | No

    Default Long integers arithmetic

    This is a typical problem of small systems which do not have native floating point support / coprocessors.

    Perhaps you should consider using 24/32 bit integers for this function. You will have to write your own functions for this or search for an app note which does this. Alternately, you may look at the microchip website for the floating point code and port it to your application though I can say it will be a lot of code and slow at that.

    To do the long integer math, you can multiply each number by 1000 and then compute the result. When you get the result, divide it by 1000 to get the integer part and keep the modulus of 1000 as the fractional part to display

    Jerson

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


    Did you find this post helpful? Yes | No

    Default

    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink Arithmetics ???

    Hi, Houa

    The first step is to use the brain ...

    by multiplying a per 1000 and B per 100 ... you get integers, and so on.

    AA = 34 030 * 1E-5
    BB = 7 230 792 * 1E-3 ... over 16 bits, so,The second step is to define the precision of the result you want ...

    X = - 7 305.5717 ok ... but what is the real meaning of the last digits ???

    Here you find THE GOOD QUESTION ....

    10 Bits for an ADC or DAC is .1 % ...
    12 Bits ......................... is .025%

    do you know lots of Pic level peripherals with a better accuracy ??? Do you know how to realise those circuits ???

    so, 1 of 12 bits of your result is 1.8, say 2 ...

    .5717 really do not mean anything here, in the real world !!!

    Now, If you really want to do maths for maths ...

    Have a look to Melabs site, you'll find two valuable solutions

    1) Microchip FP files to " include" to your program
    2) arithmetic co-processor ... wich is the most simple Way.

    The last solution is to change compiler ( no, no ... not on the head ) or processor ... where those solutions are already cooked implemented.

    Hope it helps you to better see the truth !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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. Pulsin Math question
    By ruijc in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 2nd April 2008, 16:15
  4. 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
  5. not quite understanding the MATH function
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th January 2006, 20:20

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