Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

  • Author

Nevermind! I found a calculation that seems to be working so far:

 

Let ( [precision=10000;
p0=Abs(number);n0=Mod(p0;1);
p1=1/Case(n0 ;n0;1);n1=Mod(p1;1);
p2=1/Case(n1 and (p1/n1<precision);n1;1);n2=Mod(p2;1);
p3=1/Case(n2 and (p1*p2/n2<precision);n2;1);n3=Mod(p3;1);
p4=1/Case(n3 and (p1*p2*p3/n3<precision);n3;1);n4=Mod(p4;1);
p5=1/Case(n4 and (p1*p2*p3*p4/n4<precision);n4;1);n5=Mod(p5;1);
p6=1/Case(n5 and (p1*p2*p3*p4*p5/n5<precision);n5;1);n6=Mod(p6;1);
p7=1/Case(n6 and (p1*p2*p3*p4*p5*p6/n6<precision);n6;1);
d=Round(p1*p2*p3*p4*p5*p6*P7;0); n=Round(p0*d;0);nf=Round(n0*d;0);
sgn=Choose(Sign(number)+1;"-";"";"");
whole=Div(n;d);
fraction=Case(d=1;"";nf;nf&"/"&d;"")];
Trim(sgn&Case(not p0;0;whole;whole&" ";"")&fraction))

I found a calculation that seems to be working so far:

 

Please give the author proper credit by including a link to the original post. I believe this one is by Bob Weaver?

 

 

I just want my decimal to display as a fraction...no constraints. Is this possible?

 

No constraints whatsoever? Yes, it is possible: just convert the decimal to a fraction using a denominator that is a power of 10, so that:

 

0.5 --> 5/10

0.75 --> 75/100

0.125 --> 125/1000

3.1428571428571429 --> 3 1428571428571429/10000000000000000

etc.

 

Whether this is useful for anything is another question. Typically one would try to reduce the fraction to the smallest integers possible, i.e.:

 

0.5 --> 5/10 --> 1/2

0.75 --> 75/100 --> 3/4

0.125 --> 125/1000 --> 1/8

 

The question then becomes what do you do with a decimal such as 0.33 - do you leave it as 33/100, or do you regard it "close enough" to be represented as 1/3?

 

Because that's what the calculation above does: if your precision parameter is 100 or lower, 0.33 will become 1/3; set it higher and it will be left as 33/100. And that's definitely a constraint.

  • Author

Thanks Comment for your help as always. I would love to give the author credit (and would have) but alas, I copied the calculation from a woman who posted on another forum who got it from some place else and she didn't reveal where she got it from. I didn't see the point in posting the link to the other forum for that reason but if you feel otherwise let me know and I'll go back and try to find it again.

Well, let's see:

 

[searching...]

 

Ah, there it is:

http://fmforums.com/forum/topic/34052-calc-to-reduce-fractions/

 

 

I copied the calculation from a woman who posted on another forum who got it from some place else and she didn't reveal where she got it from.

 

Perhaps you should reprimand her as I did you ... :smile:

  • Author

http://www.filemakertoday.com/com/showthread.php/10520-Decimals-to-Fractions-Newbie

Here is where I got it from, at the very bottom. It didn't even occur to me it could have come from here because my search on this forum never turned up the string you found. I see now that someone had posted the link for her that I had somehow completely overlooked. Her comment led me to believe she found it somewhere else on her own. It was not my intention to not give credit where it was due.

 

On another note, would you kindly be able to lead me to a thread that discusses the ability to do it the other way around, i.e. display a fraction entered into a field as a decimal? Once again my searches are turning up nothing but dead ends.

do it the other way around, i.e. display a fraction entered into a field as a decimal?

 

This is not a matter of displaying - you just need to calculate the decimal value of the fraction by dividing the numerator by the denominator and (if you have it) adding the integer part. The real question here is how will you enter the fractions into a (text) field. Ideally, you would use three different number fields for this purpose. Otherwise you need to set up some rules and enforce them.

 

For example, if there always will be a space between the integer and the numerator (but not anywhere else) you could do =

Evaluate ( Substitute ( Fraction ; " " ; "+"  ) )

This will convert "5/8" to .625, "1 1/4" to 1.25 and "28" to 28 - but it will error at "1 / 2".

  • Author

Got it. Thank you once again Comment. I wish I had your brain! ;)

Get in LINE! 

 

:tongue3:

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.