A class that defines the rounding strategy to be used when formatting numbers in NumberFormatter.
More...
#include <numberformatter.h>

static Rounder  unlimited () 
 Show all available digits to full precision. More...


static FractionRounder  integer () 
 Show numbers rounded if necessary to the nearest integer. More...


static FractionRounder  fixedFraction (int32_t minMaxFractionPlaces) 
 Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator). More...


static FractionRounder  minFraction (int32_t minFractionPlaces) 
 Always show at least a certain number of fraction places after the decimal separator, padding with zeros if necessary. More...


static FractionRounder  maxFraction (int32_t maxFractionPlaces) 
 Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator). More...


static FractionRounder  minMaxFraction (int32_t minFractionPlaces, int32_t maxFractionPlaces) 
 Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator); in addition, always show at least a certain number of places after the decimal separator, padding with zeros if necessary. More...


static DigitRounder  fixedDigits (int32_t minMaxSignificantDigits) 
 Show numbers rounded if necessary to a certain number of significant digits or significant figures. More...


static DigitRounder  minDigits (int32_t minSignificantDigits) 
 Always show at least a certain number of significant digits/figures, padding with zeros if necessary. More...


static DigitRounder  maxDigits (int32_t maxSignificantDigits) 
 Show numbers rounded if necessary to a certain number of significant digits/figures. More...


static DigitRounder  minMaxDigits (int32_t minSignificantDigits, int32_t maxSignificantDigits) 
 Show numbers rounded if necessary to a certain number of significant digits/figures; in addition, always show at least a certain number of significant digits, padding with zeros if necessary. More...


static IncrementRounder  increment (double roundingIncrement) 
 Show numbers rounded if necessary to the closest multiple of a certain rounding increment. More...


static CurrencyRounder  currency (UCurrencyUsage currencyUsage) 
 Show numbers rounded and padded according to the rules for the currency unit. More...



struct  impl::MacroProps 

struct  impl::MicroProps 

class  impl::NumberFormatterImpl 

class  impl::MutablePatternModifier 

class  impl::LongNameHandler 

class  impl::ScientificHandler 

class  impl::CompactHandler 

class  FractionRounder 

class  CurrencyRounder 

class  IncrementRounder 

A class that defines the rounding strategy to be used when formatting numbers in NumberFormatter.
To create a Rounder, use one of the factory methods.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
Definition at line 571 of file numberformatter.h.
◆ currency()
Show numbers rounded and padded according to the rules for the currency unit.
The most common rounding settings for currencies include Rounder.fixedFraction(2)
, Rounder.integer()
, and Rounder.increment(0.05)
for cash transactions ("nickel rounding").
The exact rounding details will be resolved at runtime based on the currency unit specified in the NumberFormatter chain. To round according to the rules for one currency while displaying the symbol for another currency, the withCurrency() method can be called on the return value of this method.
 Parameters

currencyUsage  Either STANDARD (for digital transactions) or CASH (for transactions where the rounding increment may be limited by the available denominations of cash or coins). 
 Returns
 A CurrencyRounder for chaining or passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
◆ fixedDigits()
static DigitRounder icu::number::Rounder::fixedDigits 
( 
int32_t 
minMaxSignificantDigits  ) 


static 
Show numbers rounded if necessary to a certain number of significant digits or significant figures.
Additionally, pad with zeros to ensure that this number of significant digits/figures are always shown.
This method is equivalent to minMaxDigits with both arguments equal.
 Parameters

minMaxSignificantDigits  The minimum and maximum number of significant digits to display (rounding if too long or padding with zeros if too short). 
 Returns
 A Rounder for chaining or passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
◆ fixedFraction()
static FractionRounder icu::number::Rounder::fixedFraction 
( 
int32_t 
minMaxFractionPlaces  ) 


static 
Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator).
Additionally, pad with zeros to ensure that this number of places are always shown.
Example output with minMaxFractionPlaces = 3:
87,650.000
8,765.000
876.500
87.650
8.765
0.876
0.088
0.009
0.000 (zero)
This method is equivalent to minMaxFraction with both arguments equal.
 Parameters

minMaxFractionPlaces  The minimum and maximum number of numerals to display after the decimal separator (rounding if too long or padding with zeros if too short). 
 Returns
 A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
◆ increment()
static IncrementRounder icu::number::Rounder::increment 
( 
double 
roundingIncrement  ) 


static 
Show numbers rounded if necessary to the closest multiple of a certain rounding increment.
For example, if the rounding increment is 0.5, then round 1.2 to 1 and round 1.3 to 1.5.
In order to ensure that numbers are padded to the appropriate number of fraction places, call withMinFraction() on the return value of this method. For example, to round to the nearest 0.5 and always display 2 numerals after the decimal separator (to display 1.2 as "1.00" and 1.3 as "1.50"), you can run:
Rounder::increment(0.5).withMinFraction(2)
 Parameters

roundingIncrement  The increment to which to round numbers. 
 Returns
 A Rounder for chaining or passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
◆ integer()
Show numbers rounded if necessary to the nearest integer.
 Returns
 A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
◆ maxDigits()
static DigitRounder icu::number::Rounder::maxDigits 
( 
int32_t 
maxSignificantDigits  ) 


static 
Show numbers rounded if necessary to a certain number of significant digits/figures.
 Parameters

maxSignificantDigits  The maximum number of significant digits to display (rounding if too long). 
 Returns
 A Rounder for chaining or passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
◆ maxFraction()
static FractionRounder icu::number::Rounder::maxFraction 
( 
int32_t 
maxFractionPlaces  ) 


static 
Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator).
Unlike the other fraction rounding strategies, this strategy does not pad zeros to the end of the number.
 Parameters

maxFractionPlaces  The maximum number of numerals to display after the decimal mark (rounding if necessary). 
 Returns
 A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
◆ minDigits()
static DigitRounder icu::number::Rounder::minDigits 
( 
int32_t 
minSignificantDigits  ) 


static 
Always show at least a certain number of significant digits/figures, padding with zeros if necessary.
Do not perform rounding (display numbers to their full precision).
NOTE: If you are formatting doubles, see the performance note in unlimited.
 Parameters

minSignificantDigits  The minimum number of significant digits to display (padding with zeros if too short). 
 Returns
 A Rounder for chaining or passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
◆ minFraction()
static FractionRounder icu::number::Rounder::minFraction 
( 
int32_t 
minFractionPlaces  ) 


static 
Always show at least a certain number of fraction places after the decimal separator, padding with zeros if necessary.
Do not perform rounding (display numbers to their full precision).
NOTE: If you are formatting doubles, see the performance note in unlimited.
 Parameters

minFractionPlaces  The minimum number of numerals to display after the decimal separator (padding with zeros if necessary). 
 Returns
 A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
◆ minMaxDigits()
static DigitRounder icu::number::Rounder::minMaxDigits 
( 
int32_t 
minSignificantDigits, 


int32_t 
maxSignificantDigits 

) 
 

static 
Show numbers rounded if necessary to a certain number of significant digits/figures; in addition, always show at least a certain number of significant digits, padding with zeros if necessary.
 Parameters

minSignificantDigits  The minimum number of significant digits to display (padding with zeros if necessary). 
maxSignificantDigits  The maximum number of significant digits to display (rounding if necessary). 
 Returns
 A Rounder for chaining or passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
◆ minMaxFraction()
static FractionRounder icu::number::Rounder::minMaxFraction 
( 
int32_t 
minFractionPlaces, 


int32_t 
maxFractionPlaces 

) 
 

static 
Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator); in addition, always show at least a certain number of places after the decimal separator, padding with zeros if necessary.
 Parameters

minFractionPlaces  The minimum number of numerals to display after the decimal separator (padding with zeros if necessary). 
maxFractionPlaces  The maximum number of numerals to display after the decimal separator (rounding if necessary). 
 Returns
 A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
◆ unlimited()
static Rounder icu::number::Rounder::unlimited 
( 
 ) 


static 
◆ withMode()
Sets the rounding mode to use when picking the direction to round (up or down).
Common values include HALF_EVEN, HALF_UP, and FLOOR. The default is HALF_EVEN.
 Parameters

roundingMode  The RoundingMode to use. 
 Returns
 A Rounder for passing to the NumberFormatter rounding() setter.
 Draft:
 This API may be changed in the future versions and was introduced in ICU 60
The documentation for this class was generated from the following file: