Hey Everyone!
I am making a meal planning app that has recipe ingredients. The quantity of these ingredients are in fraction form. (Ex. 1/2 cup of corn)

Has anyone made an app with fractions? If so:

How do you store this information?

How do you do calculations on fractions (adding, subtracting)

This is very interesting. I have done a lot of work with calculations, but not in fractions.

Just my initial gut instinct is that you will need to do the calculations in decimals, and then convert it back to a fraction using a lookup table to match the decimal to the corresponding fraction.

For example, your lookup table might have a numeric value with a corresponding fraction text value.

0.25 1/4 cup
0.33 1/3 cup
0.5 1/2 cup
0.67 2/3 cup
0.75 3/4 cup
1 1 cup

So if you did a calculation to double the 1/2 cup it would be 0.5 x 2 = 1.

Now to make sure it works with tiny deviations such as 3 x 0.33 = 0.99 not 1, you may need to either round or set up your lookup table with low and high ranges and find the value where the calculated number is >= the low range AND <= the high range. So 1cup might have a low of .95 and a high of 1.05.

Hey @robert!
This is a great solution! The measurements are pretty finite so I can’t imagine the calculations would get too crazy and yes I could probably just round to 2 digits after the decimal to solve for ranges. I’ll give this a shot to see if it works!

In case anyone is interested in the solution here, I took what Robert said and implemented it:

Create a new custom data type called Fraction Lookup

Create fields: Decimal , Denominator, Numerator inside the new data type (all fields are type number)

In the Design tab create a group that has Type of Content = Fraction Lookup and data source = Search for Fraction Lookups: First Item where the constraint is Decimal = The_Name_Of_Your_Decimal_Field

Inside that group create a text field that has content = [sup]Parent group's Fraction Lookup's Numerator[/sup] / [sup]Parent group's Fraction Lookup's Denominator[/sub]

Let me know if you have any questions!
It’s working in my app plantplanner.io in the Grocery List section.