×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    15

    How to solve this math in MIDP1.0?

    Hello,

    I have a form where a user inputs following fields:

    F = int
    f = decimal in string format ie. "2.8"
    distance = integer

    Static variables are:

    CoC = (int)(19/1000);
    int mm = 1;

    How would I go about forming a following formula in MIDP1.0 that doesn't support decimals. The only problem here that I am aware of is the value of f and the outcome of all of teh below formulas, as they pretty sure will outcome to a decimal.

    a = ((DD/(1+((DD*CoC*f)/(F*F))))*(mm))/1000;
    b = ((DD/(1-((DD*CoC*f)/(F*F))))*(mm))/1000;
    d = ((F*F)/(f*CoC)*(mm))/1000;

    Is there anyone who could explain to me how to make these kind of formulas work in MIDP1.0 either here or by emailing me to artur@majgaj.com

    Thank you so much in advance for your help!

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Fixed point math. Google for tutorials on it. There are also a few MIDP libraries that implement it like MathFP. And there's Henson's Float class too.

    shmoove

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    15
    Originally posted by shmoove
    Fixed point math. Google for tutorials on it. There are also a few MIDP libraries that implement it like MathFP. And there's Henson's Float class too.

    shmoove
    I did read those sources, but I'm not sure on how to apply the fixed point math classes to the formula I provided... =(

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Well, MathFP has a few methods called toFP() that can convert your various values into fixed point format. And it also has a bunch of arithmethic and trigonometric (like add(), mul(), div()) that you can use to implement your equations.

    shmoove

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    15
    Would anyone by any chance might have the FloatConvW.zip file from Hanson's website as the link is broken and the author hasn't responsed despite many requests.

  6. #6
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Moscow/Russia
    Posts
    258
    Originally posted by agajewski
    Would anyone by any chance might have the FloatConvW.zip file from Hanson's website as the link is broken and the author hasn't responsed despite many requests.
    Henson(!) is not Hanson(!) and I didn't see your requests....
    P.S. Link is repaired...

Posting Permissions

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