FORMATFRACTION function
Number
The number to format.
NumberOfDenominatorDigits
The number of digits the denominator of the fraction should have. This
parameter must be set to BLANK()BLANK() or be omitted if a
specific denominator should be used. In that case, the
Denominator
parameter must be provided.
Denominator
The denominator of the fraction. This parameter must be set to
BLANK()BLANK() or be omitted if the
denominator is only specified in terms of the number of digits it
should have. In that case, the NumberOfDenominatorDigits
parameter must be provided.
OmitThousandsSeparators
FALSE to include thousands separators and TRUE to exclude them. If omitted, FALSE is assumed.
MinimumNumberOfIntegerDigits
The minimum number of digits the integer part should be formatted with. If this parameter is greater than the number of digits of the integer part, it is padded with zeroes, meaning that 123 formatted with a minimum of five integer digits is rendered as "00123." If omitted, 1 is assumed.
LeadingUnit
The leading unit that should precede the returned formatted number.
TrailingUnit
The trailing unit that should follow the returned formatted number.
Returns
A formatted textual representation of a number, which includes an integer followed by a fraction.
Returns a number as text, formatted as an integer followed by a fraction (a denominator, a division symbol and a numerator). FORMATFRACTION(3.75, 1)FORMATFRACTION(3,75; 1) returns "3 3/4".
In the preceding example, the second parameter is set to 1, specifying the number of digits in the denominator (the number to the right of the "/" symbol). FORMATFRACTION(3.66, 1)FORMATFRACTION(3,66; 1) returns "3 2/3" and FORMATFRACTION(3.66, 2)FORMATFRACTION(3,66; 2) returns "3 33/50".
This function is specific to Calcapp.
Setting the denominator explicitly
The denominator can also be set explicitly, ensuring that eights or sixteenths are returned, for instance. When the denominator is given explicitly as the third parameter, the second parameter must be set to BLANK()BLANK() or be omitted.
To specify a denominator while omitting the second parameter, the denominator
parameter must be named. To name a parameter, precede its value with its name
and :
.
These equivalent formulas return "3 3/4" (because 3.66 is closer to "3 3/4" than to either "3 2/4" or "4 0/4"):
These equivalent formulas return "3 5/8":
Finally, these equivalent formulas return "3 11/16":
Thousands separators
This formula returns "1,024 4/5" if the language of the app is set to US English and "1.024 4/5" if the language of the app is set to Spanish:
By default, FORMATFRACTION includes thousands separators, meaning that a special character is used to separate groups of thousands (" " for US English and "." for Spanish).
The fourth parameter, OmitThousandsSeparators
, may be set to
TRUE to prevent thousands separators from being used. This formula returns
"1024 4/5", regardless of the language setting of the app:
If the second and fourth parameters are both specified, the third parameter must be given as BLANK()BLANK(). Alternatively, the fourth parameter can be named explicitly in the formula:
Padding the integer with leading zeroes
The fifth parameter, MinimumNumberOfIntegerDigits
, may be used
to pad the number with leading zeroes. These equivalent formulas return "0003
3/4":
Related functions
- Use FORMATNUMBER to format regular numbers.
- Use FORMATPERCENTAGE to format percentages (0.75 can be formatted as "75%").
- Use FORMATSCIENTIFIC to use scientific notation (1,500 can be formatted as "1.5E+03").
- Use FIXED to round a number to the left of the decimal separator (7,523 can be formatted as "7,500").
- Use PARSEFRACTION to turn the text returned from this function back into a number.
Examples
Returns "3 3/4". The number of digits of the denominator (appearing to the right of the "/" symbol) is set to 1.
Returns the array { "3 3/4", "2 3/4" }{ "3 3/4"; "2 3/4" }. The number of digits of the denominator (appearing to the right of the "/" symbol) is set to 1. When invoked with an array, FORMATFRACTION is invoked once per array element and the results are collected in an array.
Returns "3 2/3". The number of digits of the denominator (appearing to the right of the "/" symbol) is set to 1.
Returns "3 33/50". The number of digits of the denominator (appearing to the right of the "/" symbol) is set to 2.
Return "3 3/4" (because 3.66 is closer to "3 3/4" than to either "3 2/4" or "4 0/4".) The denominator is set explicitly to 4.
Returns "3 5/8". The denominator is set explicitly to 8.
Returns "3 11/16". The denominator is set explicitly to 16.
Returns "3 11/16". The denominator is set explicitly to 16 by naming the
Denominator
parameter. As the third parameter is named, the
second optional parameter is not needed and can be left out.
Returns "1,024 4/5" if the language of the app is set to US English. "1.024 4/5" is returned if the language of the app is set to Spanish.
Returns "1024 4/5", without a thousands separator.
Returns "0003 3/4", using at least four digits for the integer part of the fraction, padding the number with leading zeroes if needed.
Returns "3 3/4 lbs". The second parameter is set to the number of digits
the denominator should have (which appears to the right of the "/"
symbol). The TrailingUnit
parameter is named explicitly and
its value set to " lbs", making that text string part of the
formatted value. By naming the parameter explicitly, the optional
parameters preceding it can be left out of the formula.