This topic is 5680 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

Can anyone help me with fractions? I want field a to be a fraction (1/15) and field b to be a fraction (1/15)? And then field c should be field a + field b = field c (calculated field) and it should display as a fraction.

Any help is greatly appreciated. Have a great day!

##### Share on other sites

You'll need to use this calculation for the three different versions of the fields you have (field a, field b and field c) substituting the correct field references. This will be fairly easy since the Let function has been employed.

Let(

Remainder = Mod(Number; 1);

Int(Number) & " " & Round(Remainder *

(Case(

Mod(Remainder * 2; 1) = 0; 2;

Mod(Remainder * 3; 1) = 0; 3;

Mod(Remainder * 4; 1) = 0; 4;

Mod(Remainder * 5; 1) = 0; 5;

Mod(Remainder * 6; 1) = 0; 6;

Mod(Remainder * 7; 1) = 0; 7;

Mod(Remainder * 8; 1) = 0; 8;

Mod(Remainder * 9; 1) = 0; 9;

Mod(Remainder * 10; 1) = 0; 10;

Mod(Remainder * 11; 1) = 0; 11;

Mod(Remainder * 12; 1) = 0; 12;

Mod(Remainder * 13; 1) = 0; 13;

Mod(Remainder * 14; 1) = 0; 14;

Mod(Remainder * 15; 1) = 0; 15;

Mod(Remainder * 16; 1) = 0; 16;

Mod(Remainder * 17; 1) = 0; 17;

Mod(Remainder * 18; 1) = 0; 18;

Mod(Remainder * 19; 1) = 0; 19;

Mod(Remainder * 20; 1) = 0; 20;

Mod(Remainder * 21; 1) = 0; 21;

Mod(Remainder * 22; 1) = 0; 22;

Mod(Remainder * 23; 1) = 0; 23;

Mod(Remainder * 24; 1) = 0; 24;

Mod(Remainder * 25; 1) = 0; 25;

Mod(Remainder * 26; 1) = 0; 26;

Mod(Remainder * 27; 1) = 0; 27;

Mod(Remainder * 28; 1) = 0; 28;

Mod(Remainder * 29; 1) = 0; 29;

Mod(Remainder * 30; 1) = 0; 30;

Mod(Remainder * 31; 1) = 0; 31; 32));0) & "/" &

(Case(Mod(Remainder * 2; 1) = 0; 2;

Mod(Remainder * 3; 1) = 0; 3;

Mod(Remainder * 4; 1) = 0; 4;

Mod(Remainder * 5; 1) = 0; 5;

Mod(Remainder * 6; 1) = 0; 6;

Mod(Remainder * 7; 1) = 0; 7;

Mod(Remainder * 8; 1) = 0; 8;

Mod(Remainder * 9; 1) = 0; 9;

Mod(Remainder * 10; 1) = 0; 10;

Mod(Remainder * 11; 1) = 0; 11;

Mod(Remainder * 12; 1) = 0; 12;

Mod(Remainder * 13; 1) = 0; 13;

Mod(Remainder * 14; 1) = 0; 14;

Mod(Remainder * 15; 1) = 0; 15;

Mod(Remainder * 16; 1) = 0; 16;

Mod(Remainder * 17; 1) = 0; 17;

Mod(Remainder * 18; 1) = 0; 18;

Mod(Remainder * 19; 1) = 0; 19;

Mod(Remainder * 20; 1) = 0; 20;

Mod(Remainder * 21; 1) = 0; 21;

Mod(Remainder * 22; 1) = 0; 22;

Mod(Remainder * 23; 1) = 0; 23;

Mod(Remainder * 24; 1) = 0; 24;

Mod(Remainder * 25; 1) = 0; 25;

Mod(Remainder * 26; 1) = 0; 26;

Mod(Remainder * 27; 1) = 0; 27;

Mod(Remainder * 28; 1) = 0; 28;

Mod(Remainder * 29; 1) = 0; 29;

Mod(Remainder * 30; 1) = 0; 30;

Mod(Remainder * 31; 1) = 0; 31; 32)))

##### Share on other sites

You can get the sum of the first two fields (assuming they're text fields) using the Evaluate() function. The values in these fields (i.e. 1/15) are ready to use formulas, so the only thing you need to do to get their sum is

Evaluate( Field A & " + " & Field B ).

To present the result as a fraction try this custom function:

http://edoshin.skeletonkey.com/2006/01/fraction_approx.html

##### Share on other sites

Welcome Mikhail,

:welcomesign:

It's great to see you here!

Although agtjazz didn't give an example with whole numbers (like 1 1/2), I wonder how much work would be necessary to accomodate them. Could the space simply be substituted with a plus?

##### Share on other sites

Hi Mikhail, and Welcome to the Forum.

I'm on my way to your site to check you the CF, However, the original poster doesn't have Advance or Developer.

##### Share on other sites

Now both you Mikhail and JMO   Ehm whats next? That Corn Walker and Jason DeLooze shows up here as well??

--sd

##### Share on other sites

Thank you for both suggestions... I will try today and see if I can get it to work for me.

You are correct- I don't have Developer or Advanced- just plain ole Filemaker Pro 8 (so would Mikhail's suggestion work for me?)

I think that the fractions will not have any whole numbers. Just 1/15 + 4/15 or 8/60

Thanks

##### Share on other sites

... http://edoshin.skeletonkey.com/2006/01/fraction_approx.html

Hi Mikhail

I have now it between "my favorites" :welcomesign:

##### Share on other sites

However, the original poster doesn't have Advance or Developer.

Oops. I didn't notice that, maybe because this is my first reply : Will pay attention to these bits of information later. That's not good, because the function is recursive and thus cannot be converted in a calculation. This means JMO's variant may be the solution.

Although agtjazz didn't give an example with whole numbers (like 1 1/2), I wonder how much work would be necessary to accomodate them. Could the space simply be substituted with a plus?

Yes, this should be enough, I think.

##### Share on other sites

I would use 4 fields for the input, so that the basic formula would be a/b + c/d.

Then, call me old-fashioned, but I would first do:

Let ( [

e = a * d + c * b ;

f = b * d ;

integer = Div ( e ; f ) ;

rem = Mod ( e ; f ) ;

/*

At this point, we need to reduce the fraction with a recursive function.

But at least the interim result:

integer & " " & rem & "/" & f

is accurate.

With a custom function to compute the GCD, you can continue to:

*/

common = GCD ( rem ; f ) ;

numerator = rem / common ;

denominator = f / common

] ;

integer & " " & numerator & "/" & denominator

)

##### Share on other sites

Although agtjazz didn't give an example with whole numbers (like 1 1/2), I wonder how much work would be necessary to accomodate them. Could the space simply be substituted with a plus?

I posted a continued fraction technique that doesn't require a custom function in this thread:

http://www.fmforums.com/forum/showtopic.php?tid/161229

It will also convert numbers greater than 1 (like 1 1/2 etc.).

##### Share on other sites

This topic is 5680 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account