### Title

Working with negative fractions

### Post

Hello,

I have a database that uses fractions, always in eighths, that I need to do math on. I've found a calculation on this form to convert these fractions to decimals so I can do the math, but converting back to a fraction to display afterwords is a little confusing.

Please see the attached file.

If I have a negative fraction with integer, like -1 7/8 (In field fractions) it converts to a decimal fine (Decimal Field) but when I convert back to a fraction from the decimal, i end up with -1 -7/8 (DecimalBackToFraction Field) I don't want this second "-" before the fraction part, so I created the field Replace that gets rid of it.

This works fine, unless my original fraction doesn't have an integer piece (- 7/8). it still converts to decimal okay, and back to a fraction fine, but then in the Replace field, it gets rid of the first "-" leaving me with 7/8 which isn't good..

How can I detect if there is an integer or not in the fractions, and display negatives and positives after the math on the decimal values accordingly..?

THanks for your help!

I'd use this expression to convert your fraction into a decimal:

Evaluate ( Substitute ( TrimAll ( Fractions ; 1 ; 1 ) ; " " ; If ( Left ( Fractions ; 1 ) = "-" ; "-" ; "+" ) ) )

I'd use this expression to convert the decimal back into eighths:

Let ( [ d = cDecimalValue ;

s = If ( d < 0 ; -1 ; 1 ) ;

i = Abs ( Int ( d ) ) ;

num = (Abs ( d ) - i ) * 8 ] ;

s * i & " " & num & "/8"

)