FractionToDecimal ( fraction )
Convert fraction string to decimal
Average rating: 4.8 (28 votes) Log in to vote
Brett Buchmiller None www.filemaker.com |
FractionToDecimal( "2 69/95" )
2.72631579
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Converts a fraction string to a numeric decimal equivalent. Part of a library of functions. Needed additional functions are mentioned in the header comments
Comments
L. Allen Poole, Creative Database Solutions NW Dec 4, 2013 |
||
This function appears to fail on integer inputs. FractionType ( 12 ) returns "Invalid," so FractionToDecimal ( 12 ) returns [null]. Rather than test for integer inputs every time I use this function, I modified it to return integer inputs unmodified. |
||
Guy Elsmore-Paddock, Inveniem Jul 12, 2019 |
||
Note that this will not work with whole numbers, or numbers that are already decimals. | ||
Guy Elsmore-Paddock, Inveniem Jul 12, 2019 |
||
Here's a modified version that works for whole numbers (might work with decimals too): /* Convert valid fraction to decimal equivalent From: https://www.briandunning.com/cf/1360 Require Functions FractionType FractionNumerator FractionDenominator © Brett Buchmiller 10-2010 Portions © Inveniem 2019 (Whole Number Handling) */ Let([ fractionType = FractionType(input) ]; Case( /* When: A whole number */ fractionType = "Whole"; input; /* When: Any other type of valid fraction */ fractionType ≠"Invalid"; FractionNumerator(input) / FractionDenominator(input) ) ) |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.