IFractionFormat Interface

Provides access to members that format fractions.

Description

The members in the IFractionFormatinterface define how the ValueToString method in the associated INumberFormat****interface formats numbers.

Use the IFractionFormat interface to either convert from a decimal fraction to a formatted fraction (using the ValueToString method) or to evaluate a formatted fraction as a decimal (using the StringToValue method). Basically, this means that ValueToString could convert an input of 0.75 to a string such as �3/4�, and 2.5 could become �2 1/2�, while StringToValue would do the reverse.

The properties FractionOption and FractionFactor give you more control over how the ValueToString conversion takes place because they allow you to use the FractionFactor to specify what denominator should be used for the output. The way in which this FractionFactor is used depends on which of the two settings (esriFractionOptionEnum) is used for the FractionOption property.

When To Use

Use the IFractionFormatinterface to determine fractions for given decimal values or to evaluate formatted fractions.

Members

Name Description
Read/write property FractionFactor The maximum number of digits for the numerator or denominator, or the denominator of the formatted fraction.
Read/write property FractionOption The fraction option determines how the numerator and denominator of the fraction are treated.

IFractionFormat.FractionFactor Property

The maximum number of digits for the numerator or denominator, or the denominator of the formatted fraction.

Public Property FractionFactor As Integer
public int FractionFactor {get; set;}

Description

The FractionFactorproperty sets or returns a value (default: 1) that specifies the maximum number of digits for the numerator or denominator, or is used as the denominator of the formatted fraction.

The way the FractionFactorproperty is used depends on how the FractionOption****property is set.

IFractionFormat.FractionOption Property

The fraction option determines how the numerator and denominator of the fraction are treated.

Public Property FractionOption As esriFractionOptionEnum
public esriFractionOptionEnum FractionOption {get; set;}

Description

The FractionOptionproperty sets or returns an option that determines how the FractionFactorproperty is used when the ValueToString****method in the associated INumberFormat interface formats numbers.

The settings for FractionOptionare:

Setting Description
**esriSpecifyFractionDigits** (Default) The FractionFactorproperty specifies the maximum number of digits the numerator or denominator is calculated to.If the value passed to ValueToStringevaluates to a fraction whose numerator or denominator has more digits than specified in the FractionFactorproperty, the formatted string will be the closest fraction to the number of digits specified. In the example, StringToValuefirst evaluates the fraction 893/1234to return a decimal value of 0.723662884927066. ValueToString can format this decimal number back to �893/1234�; however, the maximum number of decimal places to be used in the output fraction is three (by default). Therefore, by default this returns a formatted result of 474/655 because this is the closest three-digit fraction to the decimal value. To calculate all four digits in the denominator and return to the original fraction, FractionFactor needs to be set to a value of 4. The caveat here is that the higher the FractionFactor setting, the more processing time it will take to figure out the fraction.
esriSpecifyFractionDenominator The FractionFactorproperty value explicitly specifies the denominator. Since the ValueToStringmethod doesn't have to calculate the denominator, the result is returned very quickly.

Remarks

For example, when using esriSpecifyFractionDenominator, if the FractionFactor is set to 8, then the resulting fraction would be given in eighths. The result will be rounded to fit the denominator specified, as both 0.75 and 0.85 become �3/4� in the example below.

When using StringToValue, neither the FractionOption nor the FractionFactor properties are used; instead, a straightforward evaluation of the fraction is carried out. For example, �5/8� returns a value of 0.625, and �6 3/4� returns 6.75.

Classes that implement IFractionFormat

Classes Description
FractionFormat An object for formatting numbers in a fraction format.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.