# Thread: How to solve this math in MIDP1.0?

1. ## 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

2. 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. 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. 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. 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. 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....