FORMATFRACTION function

FORMATFRACTION(Number, NumberOfDenominatorDigits?, Denominator?, OmitThousandsSeparators?, MinimumNumberOfIntegerDigits?, LeadingUnit?, TrailingUnit?) FORMATFRACTION(Number; NumberOfDenominatorDigits?; Denominator?; OmitThousandsSeparators?; MinimumNumberOfIntegerDigits?; LeadingUnit?; TrailingUnit?)

Number

Number or { Number }

The number to format.

NumberOfDenominatorDigits

Number or { Number } (optional)

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

Number or { Number } (optional)

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

Logical or { Logical } (optional)

FALSE to include thousands separators and TRUE to exclude them. If omitted, FALSE is assumed.

MinimumNumberOfIntegerDigits

Number or { Number } (optional)

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

Text or { Text } (optional)

The leading unit that should precede the returned formatted number.

TrailingUnit

Text or { Text } (optional)

The trailing unit that should follow the returned formatted number.

Returns

Text or { Text }

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"):

FORMATFRACTION(3.66, BLANK(), 4)FORMATFRACTION(3,66; BLANK(); 4)
FORMATFRACTION(3.66, Denominator: 4)FORMATFRACTION(3,66; Denominator: 4)

These equivalent formulas return "3 5/8":

FORMATFRACTION(3.66, BLANK(), 8)FORMATFRACTION(3,66; BLANK(); 8)
FORMATFRACTION(3.66, Denominator: 8)FORMATFRACTION(3,66; Denominator: 8)

Finally, these equivalent formulas return "3 11/16":

FORMATFRACTION(3.66, BLANK(), 16)FORMATFRACTION(3,66; BLANK(); 16)
FORMATFRACTION(3.66, Denominator: 16)FORMATFRACTION(3,66; Denominator: 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:

FORMATFRACTION(1024.816, 1)FORMATFRACTION(1024,816; 1)

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:

FORMATFRACTION(1024.816, 1, BLANK(), TRUE)FORMATFRACTION(1024,816; 1; BLANK(); TRUE)

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:

FORMATFRACTION(1024.816, 1, OmitThousandsSeparators: TRUE)FORMATFRACTION(1024,816; 1; OmitThousandsSeparators: TRUE)

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":

FORMATFRACTION(3.75, 1, BLANK(), TRUE, 4)FORMATFRACTION(3,75; 1; BLANK(); TRUE; 4)
FORMATFRACTION(3.75, 1, OmitThousandsSeparators: TRUE, MinimumNumberOfIntegerDigits: 4)FORMATFRACTION(3,75; 1; OmitThousandsSeparators: TRUE; MinimumNumberOfIntegerDigits: 4)

Related functions

Examples

FORMATFRACTION(3.75, 1)FORMATFRACTION(3,75; 1)

Returns "3 3/4". The number of digits of the denominator (appearing to the right of the "/" symbol) is set to 1.

FORMATFRACTION({ 3.75, 2.75 }, 1)FORMATFRACTION({ 3,75; 2,75 }; 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.

FORMATFRACTION(3.66, 1)FORMATFRACTION(3,66; 1)

Returns "3 2/3". The number of digits of the denominator (appearing to the right of the "/" symbol) is set to 1.

FORMATFRACTION(3.66, 2)FORMATFRACTION(3,66; 2)

Returns "3 33/50". The number of digits of the denominator (appearing to the right of the "/" symbol) is set to 2.

FORMATFRACTION(3.66, BLANK(), 4)FORMATFRACTION(3,66; BLANK(); 4)

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.

FORMATFRACTION(3.66, BLANK(), 8)FORMATFRACTION(3,66; BLANK(); 8)

Returns "3 5/8". The denominator is set explicitly to 8.

FORMATFRACTION(3.66, BLANK(), 16)FORMATFRACTION(3,66; BLANK(); 16)

Returns "3 11/16". The denominator is set explicitly to 16.

FORMATFRACTION(3.66, Denominator: 16)FORMATFRACTION(3,66; Denominator: 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.

FORMATFRACTION(1024.816, 1)FORMATFRACTION(1024,816; 1)

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.

FORMATFRACTION(1024.816, 1, BLANK(), TRUE)FORMATFRACTION(1024,816; 1; BLANK(); TRUE)

Returns "1024 4/5", without a thousands separator.

FORMATFRACTION(3.75, 1, BLANK(), TRUE, 4)FORMATFRACTION(3,75; 1; BLANK(); TRUE; 4)

Returns "0003 3/4", using at least four digits for the integer part of the fraction, padding the number with leading zeroes if needed.

FORMATFRACTION(3.75, 1, TrailingUnit: " lbs")FORMATFRACTION(3,75; 1; TrailingUnit: " lbs")

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.