agtjazz Posted May 8, 2006 Posted May 8, 2006 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!
John Mark Osborne Posted May 8, 2006 Posted May 8, 2006 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)))
Mikhail Edoshin Posted May 9, 2006 Posted May 9, 2006 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
Ender Posted May 9, 2006 Posted May 9, 2006 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?
Lee Smith Posted May 9, 2006 Posted May 9, 2006 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.
Søren Dyhr Posted May 9, 2006 Posted May 9, 2006 Now both you Mikhail and JMO Ehm whats next? That Corn Walker and Jason DeLooze shows up here as well?? --sd
agtjazz Posted May 9, 2006 Author Posted May 9, 2006 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
Raybaudi Posted May 9, 2006 Posted May 9, 2006 ... http://edoshin.skeletonkey.com/2006/01/fraction_approx.html Hi Mikhail great stuff to read and to study in your site ! I have now it between "my favorites" :welcomesign:
Mikhail Edoshin Posted May 9, 2006 Posted May 9, 2006 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.
comment Posted May 10, 2006 Posted May 10, 2006 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 )
BobWeaver Posted May 10, 2006 Posted May 10, 2006 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.).
Recommended Posts
This topic is 6835 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now