setFloatingPointFormat:left:right:
Sets the auto-ranging and floating point number format of the receiver’s cell.
Declaration
- (void) setFloatingPointFormat:(BOOL) autoRange left:(NSUInteger) leftDigits right:(NSUInteger) rightDigits;Parameters
- autoRange:
If True, auto-ranging is enabled, otherwise it is disabled.
- leftDigits:
The number of digits to display to the left of the decimal point.
- rightDigits:
The number of digits to display to the right of the decimal point.
Discussion
Sets whether floating-point numbers are auto-ranged in the receiver and sets the sizes of the fields to the left and right of the decimal point. If autoRange is false, leftDigits specifies the maximum number of digits to the left of the decimal point, and rightDigits specifies the number of digits to the right (the fractional digit places will be padded with zeros to fill this width). However, if a number is too large to fit its integer part in leftDigits digits, as many places as are needed on the left are effectively removed from rightDigits when the number is displayed.
If autoRange is true, leftDigits and rightDigits are simply added to form a maximum total field width for the receiver (plus 1 for the decimal point). The fractional part will be padded with zeros on the right to fill this width, or truncated as much as possible (up to removing the decimal point and displaying the number as an integer). The integer portion of a number is never truncated—that is, it is displayed in full no matter what the field width limit is.
The following example sets a cell used to display dollar amounts up to 99,999.99:
[[currencyDollarsField cell] setEntryType:NSFloatType];
[[currencyDollarsField cell] setFloatingPointFormat:NO left:5 right:2];