ICU 75.1 75.1
|
A formatter that formats numbers in user-friendly scientific notation. More...
#include <scientificnumberformatter.h>
Public Member Functions | |
ScientificNumberFormatter * | clone () const |
Returns a copy of this object. | |
virtual | ~ScientificNumberFormatter () |
Destructor. | |
UnicodeString & | format (const Formattable &number, UnicodeString &appendTo, UErrorCode &status) const |
Formats a number into user friendly scientific notation. | |
Public Member Functions inherited from icu::UObject | |
virtual | ~UObject () |
Destructor. | |
virtual UClassID | getDynamicClassID () const |
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class. | |
Static Public Member Functions | |
static ScientificNumberFormatter * | createSuperscriptInstance (DecimalFormat *fmtToAdopt, UErrorCode &status) |
Creates a ScientificNumberFormatter instance that uses superscript characters for exponents. | |
static ScientificNumberFormatter * | createSuperscriptInstance (const Locale &locale, UErrorCode &status) |
Creates a ScientificNumberFormatter instance that uses superscript characters for exponents for this locale. | |
static ScientificNumberFormatter * | createMarkupInstance (DecimalFormat *fmtToAdopt, const UnicodeString &beginMarkup, const UnicodeString &endMarkup, UErrorCode &status) |
Creates a ScientificNumberFormatter instance that uses markup for exponents. | |
static ScientificNumberFormatter * | createMarkupInstance (const Locale &locale, const UnicodeString &beginMarkup, const UnicodeString &endMarkup, UErrorCode &status) |
Creates a ScientificNumberFormatter instance that uses markup for exponents for this locale. | |
A formatter that formats numbers in user-friendly scientific notation.
Sample code:
UErrorCode status = U_ZERO_ERROR; LocalPointer<ScientificNumberFormatter> fmt( ScientificNumberFormatter::createMarkupInstance( "en", "<sup>", "</sup>", status)); if (U_FAILURE(status)) { return; } UnicodeString appendTo; // appendTo = "1.23456x10<sup>-78</sup>" fmt->format(1.23456e-78, appendTo, status);
Definition at line 52 of file scientificnumberformatter.h.
|
virtual |
Destructor.
|
inline |
Returns a copy of this object.
Caller must free returned copy.
Definition at line 121 of file scientificnumberformatter.h.
|
static |
Creates a ScientificNumberFormatter instance that uses markup for exponents for this locale.
locale | The locale |
beginMarkup | the markup to start superscript. |
endMarkup | the markup to end superscript. |
status | error returned here. |
|
static |
Creates a ScientificNumberFormatter instance that uses markup for exponents.
fmtToAdopt | The DecimalFormat which must be configured for scientific notation. |
beginMarkup | the markup to start superscript. |
endMarkup | the markup to end superscript. |
status | error returned here. |
|
static |
Creates a ScientificNumberFormatter instance that uses superscript characters for exponents for this locale.
locale | The locale |
status | error returned here. |
|
static |
Creates a ScientificNumberFormatter instance that uses superscript characters for exponents.
fmtToAdopt | The DecimalFormat which must be configured for scientific notation. |
status | error returned here. |
UnicodeString & icu::ScientificNumberFormatter::format | ( | const Formattable & | number, |
UnicodeString & | appendTo, | ||
UErrorCode & | status | ||
) | const |
Formats a number into user friendly scientific notation.
number | the number to format. |
appendTo | formatted string appended here. |
status | any error returned here. |