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, or a blank value 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, or a blank value 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(). FORMATFRACTION(3.66, BLANK(), 4)FORMATFRACTION(3,66; BLANK(); 4) returns "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(), 8)FORMATFRACTION(3,66; BLANK(); 8) returns "3 5/8" and FORMATFRACTION(3.66, BLANK(), 16)FORMATFRACTION(3,66; BLANK(); 16) returns "3 11/16".

Thousands separators

FORMATFRACTION(1024.816, 1)FORMATFRACTION(1024,816; 1) returns "1,024 4/5" in 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, using a special character to separate groups of thousands (" " for US English and "." for Spanish).

The fourth parameter may be set to TRUE to prevent thousands separators from being used. FORMATFRACTION(1024.816, 1, BLANK(), TRUE)FORMATFRACTION(1024,816; 1; BLANK(); TRUE) 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().

Padding the integer with leading zeroes

The fifth parameter may be used to set the minimum number of integer digits. In practice, this pads the number with leading zeroes. FORMATFRACTION(3.75, 1, BLANK(), TRUE, 4)FORMATFRACTION(3,75; 1; BLANK(); TRUE; 4) returns "0003 3/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(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, BLANK(), BLANK(), BLANK(), BLANK(), " lbs")FORMATFRACTION(3,75; 1; BLANK(); BLANK(); BLANK(); BLANK(); " 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). All other parameters are set to BLANK()BLANK() to make them use their default values if omitted, except for the trailingUnit parameter, which is set to " lbs", making that text string part of the formatted value.